diff options
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r-- | winsup/cygwin/spawn.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 170f37a8d..e5152c0e7 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -620,6 +620,9 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, SetHandleInformation (wr_proc_pipe, HANDLE_FLAG_INHERIT, 0); SetHandleInformation (parent, HANDLE_FLAG_INHERIT, 0); } + /* FIXME: racy */ + if (mode != _P_OVERLAY) + SetHandleInformation (my_wr_proc_pipe, HANDLE_FLAG_INHERIT, 0); parent_winpid = GetCurrentProcessId (); /* When ruid != euid we create the new process under the current original @@ -724,10 +727,9 @@ loop: } } - /* Restore impersonation. In case of _P_OVERLAY this isn't - allowed since it would overwrite child data. */ - if (mode != _P_OVERLAY || !rc) - ::cygheap->user.reimpersonate (); + if (mode != _P_OVERLAY) + SetHandleInformation (my_wr_proc_pipe, HANDLE_FLAG_INHERIT, + HANDLE_FLAG_INHERIT); /* Set errno now so that debugging messages from it appear before our final debugging message [this is a general rule for debugging @@ -748,9 +750,16 @@ loop: be closed otherwise. Don't need to do this for 'parent' since it will be closed in every case. See FIXME above. */ if (!iscygwin () && mode == _P_OVERLAY) - SetHandleInformation (wr_proc_pipe, HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT); + SetHandleInformation (wr_proc_pipe, HANDLE_FLAG_INHERIT, + HANDLE_FLAG_INHERIT); if (wr_proc_pipe == my_wr_proc_pipe) wr_proc_pipe = NULL; /* We still own it: don't nuke in destructor */ + + /* Restore impersonation. In case of _P_OVERLAY this isn't + allowed since it would overwrite child data. */ + if (mode != _P_OVERLAY) + ::cygheap->user.reimpersonate (); + res = -1; goto out; } |