diff options
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Message_Block.h | 2 | ||||
-rw-r--r-- | ace/Process.cpp | 20 | ||||
-rw-r--r-- | ace/Process_Manager.cpp | 14 |
3 files changed, 23 insertions, 13 deletions
diff --git a/ace/Message_Block.h b/ace/Message_Block.h index e9bce3848e2..7de3ef7d7d7 100644 --- a/ace/Message_Block.h +++ b/ace/Message_Block.h @@ -10,7 +10,7 @@ // Message_Block.h // // = AUTHOR -// Doug Schmidt +// Douglas C. Schmidt <schmidt@cs.wustl.edu> // // ============================================================================ diff --git a/ace/Process.cpp b/ace/Process.cpp index fe025c50c34..c4a3a2249b8 100644 --- a/ace/Process.cpp +++ b/ace/Process.cpp @@ -116,16 +116,16 @@ ACE_Process::spawn (ACE_Process_Options &options) // process group, try to set our pgid to it. (This will allow // Process_Manager to wait for Processes by process-group.) if (options.getgroup () != ACE_INVALID_PID - && this->child_id_ == 0) - ACE_OS::setpgid (0, - options.getgroup ()); - - if (this->child_id_ == 0) { - child ( ACE_OS::getppid () ); - } else - if (this->child_id_ != -1) { - parent (this->child_id_); - } + && this->child_id_ == 0 + && ACE_OS::setpgid (0, options.getgroup ()) < 0) + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p.\n"), + ASYS_TEXT ("ACE_Process::spawn: setpgid failed."))); + + if (this->child_id_ == 0) + child (ACE_OS::getppid ()); + else if (this->child_id_ != -1) + parent (this->child_id_); // If we're not supposed to exec, return the process id. if (ACE_BIT_ENABLED (options.creation_flags (), diff --git a/ace/Process_Manager.cpp b/ace/Process_Manager.cpp index be9585a12f5..542059f4d67 100644 --- a/ace/Process_Manager.cpp +++ b/ace/Process_Manager.cpp @@ -168,6 +168,15 @@ ACE_Process_Manager::open (size_t size, { ACE_TRACE ("ACE_Process_Manager::open"); + // Set up a process group so that the thread that opened this + // Manager will be able to put children into its own group and wait + // for them. + if (ACE_OS::setpgid (0, 0) == -1) + ACE_ERROR ((LM_WARNING, + ASYS_TEXT ("%p.\n"), + ASYS_TEXT ("ACE_Process_Manager::open: can't create a " + "process group; some wait functions may fail"))); + if (r) { ACE_Event_Handler::reactor (r); @@ -420,8 +429,6 @@ ACE_Process_Manager::spawn (ACE_Process_Options &options) ACE_Managed_Process, ACE_INVALID_PID); - options.setgroup (ACE_OS::getpid ()); - return spawn (process, options); } @@ -433,6 +440,9 @@ ACE_Process_Manager::spawn (ACE_Process *process, { ACE_TRACE ("ACE_Process_Manager::spawn"); + if (options.getgroup () == ACE_INVALID_PID) + options.setgroup (ACE_OS::getpid ()); + pid_t pid = process->spawn (options); // Only include the pid in the parent's table. |