1 #include "ace/OS_NS_unistd.h"
2 #include "ace/Log_Msg.h"
4 #include "ace/Process_Manager.h"
6 static const int NCHILDREN
= 2;
8 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
10 if (argc
> 1) // Running as a child.
14 else // Running as a parent.
16 // Get the processwide process manager.
17 ACE_Process_Manager
* pm
= ACE_Process_Manager::instance ();
19 // Specify the options for the new processes
21 ACE_Process_Options options
;
22 options
.command_line (ACE_TEXT ("%s a"), argv
[0]);
24 // Spawn two child processes.
25 pid_t pids
[NCHILDREN
];
26 pm
->spawn_n (NCHILDREN
, options
, pids
);
28 // Destroy the first child.
29 pm
->terminate (pids
[0]);
31 // Wait for the child we just terminated.
33 pm
->wait (pids
[0], &status
);
35 // Get the results of the termination.
37 #if !defined(ACE_WIN32)
38 if (WIFSIGNALED (status
) != 0)
40 ACE_TEXT ("%d died because of a signal ")
41 ACE_TEXT ("of type %d\n"),
42 pids
[0], WTERMSIG (status
)));
46 ACE_TEXT ("The process terminated with exit code %d\n"),
50 // Wait for all (only one left) of the