1 #include "ace/Shared_Memory_MM.h"
2 #include "ace/Log_Msg.h"
3 #include "ace/OS_NS_errno.h"
4 #include "ace/OS_NS_unistd.h"
5 #include "ace/OS_NS_stdlib.h"
8 ACE_TCHAR shm_key
[] = ACE_TEXT ("/tmp/fooXXXXXX");
13 ACE_Shared_Memory
*shm_client
= new ACE_Shared_Memory_MM (shm_key
);
14 char *shm
= (char *) shm_client
->malloc ();
16 for (char *s
= shm
; *s
!= '\0'; s
++)
26 ACE_Shared_Memory
*shm_server
= new ACE_Shared_Memory_MM (shm_key
, SHMSZ
);
27 char *shm
= (char *) shm_server
->malloc ();
30 for (char c
= 'a'; c
<= 'z'; c
++)
35 // Perform a busy wait (ugh)
39 if (shm_server
->remove () < 0)
40 ACE_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"), ACE_TEXT ("remove")));
41 ACE_OS::unlink (shm_key
);
45 ACE_TMAIN (int, ACE_TCHAR
*[])
47 if (ACE_OS::mkstemp (shm_key
) == 0
48 || (ACE_OS::unlink (shm_key
) == -1 && errno
== EPERM
))
49 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p\n"), shm_key
), 1);
51 switch (ACE_OS::fork ())
54 ACE_ERROR_RETURN ((LM_ERROR
, ACE_TEXT ("%p\n"), ACE_TEXT ("fork")), 1);
56 // Make sure the server starts up first.