summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 940f8d170..c9a9c3a11 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -494,9 +494,13 @@ skip_arg_parsing:
}
init_child_info (chtype, ciresrv, (mode == _P_OVERLAY) ? myself->pid : 1, spr);
+ if (mode != _P_OVERLAY ||
+ !DuplicateHandle (hMainProc, myself.shared_handle (), hMainProc,
+ &ciresrv->myself_pinfo, 0,
+ TRUE, DUPLICATE_SAME_ACCESS))
+ ciresrv->myself_pinfo = NULL;
LPBYTE resrv = si.lpReserved2 + sizeof *ciresrv;
-# undef ciresrv
if (fdtab.linearize_fd_array (resrv, len) < 0)
{
@@ -611,6 +615,9 @@ skip_arg_parsing:
free (envblock);
MALLOC_CHECK;
+ if (ciresrv->myself_pinfo)
+ CloseHandle (ciresrv->myself_pinfo);
+
/* Set errno now so that debugging messages from it appear before our
final debugging message [this is a general rule for debugging
messages]. */