diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-11-11 22:30:10 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1999-11-11 22:30:10 +0000 |
commit | 8f4c9d969429f5ec8fa084bc83d1923880346e2b (patch) | |
tree | 2a0753571d90aded6700b445172f481300feaae6 | |
parent | db8cd3b95b8b7ed4d28d1241d2a816d91b84a43f (diff) | |
download | ATCD-8f4c9d969429f5ec8fa084bc83d1923880346e2b.tar.gz |
ChangeLogTag:Thu Nov 11 12:10:40 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
-rw-r--r-- | ChangeLog-99b | 13 | ||||
-rw-r--r-- | ace/Message_Block.h | 2 | ||||
-rw-r--r-- | ace/Process.cpp | 20 | ||||
-rw-r--r-- | ace/Process_Manager.cpp | 14 |
4 files changed, 36 insertions, 13 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index 35ab27f278a..057741b36e6 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,3 +1,16 @@ +Thu Nov 11 12:10:40 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Process_Manager.cpp, + ace/Process.cpp: It looks like the thread that's going to use + the Process_Manager object must do a setpgid (0, 0) in order to + establish a process group for its children. Apparently, when + you run the test program from the command line, the shell sets + the process up in a group of its own, but when you run it from + the test script, it's a member of the script's group. In the + latter case, when you spawn a child process, you can't add it to + your own group (because your group doesn't exist!). Thanks to + Dave Madden <dhm@mersenne.com> for contributing this fix. + Thu Nov 11 01:54:55 1999 Luther J Baker <ljb1@cs.wustl.edu> * ace/Log_Msg.h (msg_ostream): 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. |