From 6daf4afb11869add20516ef4ae451898840f1ffa Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Wed, 21 Mar 2012 05:23:13 +0000 Subject: * child_info.h: Reset magic number. (child_info_spawn::wait_for_myself): Move function to sigproc.cc. * pinfo.cc (is_toplevel_proc): Delete unneeded variable. * sigproc.cc (child_info_spawn::wait_for_myself): Move function from header to here. Do all setup required to properly wait for top-level execed process to exit. * spawn.cc (child_info_spawn::worker): Attempt to properly handle _P_DETACH. Set wr_proc_pipe if top-level process even when execing. Just call wait_for_myself() to... wait for myself. Don't call cleanup twice. --- winsup/cygwin/spawn.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'winsup/cygwin/spawn.cc') diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index f5501a540..f3d917aed 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -614,10 +614,12 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, c_flags |= CREATE_NEW_PROCESS_GROUP; refresh_cygheap (); - if (chtype == _CH_EXEC) - wr_proc_pipe = my_wr_proc_pipe; - else + if (mode == _P_DETACH) + /* all set */; + else if (chtype != _CH_EXEC || !my_wr_proc_pipe) prefork (); + else + wr_proc_pipe = my_wr_proc_pipe; /* When ruid != euid we create the new process under the current original account and impersonate in child, this way maintaining the different @@ -853,14 +855,8 @@ loop: close_all_files (true); if (!my_wr_proc_pipe && WaitForSingleObject (pi.hProcess, 0) == WAIT_TIMEOUT) - { - extern bool is_toplevel_proc; - is_toplevel_proc = true; - myself.remember (false); - wait_for_myself (); - } + wait_for_myself (); } - this->cleanup (); myself.exit (EXITCODE_NOSET); break; case _P_WAIT: -- cgit v1.2.3