1 #include "ace/config-all.h"
2 #include "ace/OS_main.h"
4 #if !defined (ACE_LACKS_FORK)
6 #include "ace/streams.h"
7 #include "ace/OS_NS_unistd.h"
8 #include "ace/OS_NS_time.h"
9 #include "ace/OS_NS_signal.h"
11 typedef void (*timerTask_t
)();
13 // Listing 1 code/ch07
14 pid_t
timerTask (int initialDelay
,
18 if (initialDelay
< 1 && interval
< 1)
21 pid_t pid
= ACE_OS::fork ();
30 ACE_OS::sleep (initialDelay
);
38 ACE_OS::sleep (interval
);
41 ACE_NOTREACHED (return 0);
45 // Listing 2 code/ch07
48 time_t now
= ACE_OS::time (0);
49 cerr
<< "The time is " << ACE_OS::ctime (&now
) << endl
;
53 void programMainLoop ()
58 // Listing 3 code/ch07
59 int ACE_TMAIN (int, ACE_TCHAR
*[])
61 pid_t timerId
= timerTask (3, 5, foo
);
63 ACE_OS::kill (timerId
, SIGINT
);
69 #include "ace/OS_NS_stdio.h"
71 int ACE_TMAIN (int, ACE_TCHAR
*[])
73 //FUZZ: disable check_for_lack_ACE_OS
74 ACE_OS::puts ("This very unportable example requires fork().\n");
75 //FUZZ: enable check_for_lack_ACE_OS
80 #endif /* ACE_LACKS_FORK */