* child_info.h (CURR_CHILD_INFO_MAGIC): Update.
(child_info::parent_wr_proc_pipe): Eliminate. * pinfo.h (_pinfo::alert_parent): Move here from pinfo class. (_pinfo::dup_proc_pipe): New method. (_pinfo::sync_proc_pipe): Ditto. * exceptions.cc (sig_handle_tty_stop): Reflect move of alert_parent. * init.cc (dll_entry): Exit with status one if main process called ExitProcess. * pinfo.cc (set_myself): Remove handling of parent_wr_proc_pipe. (_pinfo::exit): Reflect move of alert_parent. Set procinfo to NULL to flag that we are exiting normally. Always use exitcode when exiting (although this could be a little racy). (pinfo::init): Set default exit to SIGTERM. This will be the exit code reported if process is terminated. (_pinfo::dup_proc_pipe): New function. (pinfo::wait): Duplicate wr_proc_pipe to the right place. Use dup_proc_pipe to move the pipe to the child. (_pinfo::sync_proc_pipe): New function. (_pinfo::alert_parent): Move to _pinfo. Make sure that wr_proc_pipe is ours before using it. * sigproc.cc (child_info::child_info): Remove handling of parent_wr_proc_pipe. * spawn.cc (spawn_guts): Pass our wr_proc_pipe to the child when execing. Ensure that exit code of cygwin process started from windows is correctly set.
This commit is contained in:
@ -796,16 +796,28 @@ spawn_guts (const char * prog_arg, const char *const *argv,
|
||||
sigproc_printf ("new process name %s", myself->progname);
|
||||
close_all_files ();
|
||||
/* If wr_proc_pipe doesn't exist then this process was not started by a cygwin
|
||||
process. So, we need to wait around until the process we've just "execed"
|
||||
dies. Use our own wait facility to wait for our own pid to exit (there
|
||||
is some minor special case code in proc_waiter and friends to accommodeate
|
||||
this). */
|
||||
process. So, we need to wait around until the process we've just "execed"
|
||||
dies. Use our own wait facility to wait for our own pid to exit (there
|
||||
is some minor special case code in proc_waiter and friends to accommodate
|
||||
this).
|
||||
|
||||
If wr_proc_pipe exists, then it should be duplicated to the child.
|
||||
If the child has exited already, that's ok. The parent will pick up
|
||||
on this fact when we exit. dup_proc_pipe also closes our end of the pipe.
|
||||
Note that wr_proc_pipe may also be == INVALID_HANDLE_VALUE. That will make
|
||||
dup_proc_pipe essentially a no-op. */
|
||||
if (!myself->wr_proc_pipe)
|
||||
{
|
||||
myself.remember (true);
|
||||
wait_for_myself = true;
|
||||
myself->wr_proc_pipe = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
{
|
||||
myself.remember (false);
|
||||
wait_for_myself = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make sure that we own wr_proc_pipe just in case we've been
|
||||
previously execed. */
|
||||
myself->sync_proc_pipe ();
|
||||
(void) myself->dup_proc_pipe (pi.hProcess);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -849,14 +861,13 @@ ForceCloseHandle (pi.hThread);
|
||||
|
||||
sigproc_printf ("spawned windows pid %d", pi.dwProcessId);
|
||||
|
||||
if (wait_for_myself)
|
||||
waitpid (myself->pid, &res, 0);
|
||||
else
|
||||
ciresrv.sync (myself, INFINITE);
|
||||
ciresrv.sync (myself, INFINITE);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case _P_OVERLAY:
|
||||
if (wait_for_myself)
|
||||
waitpid (myself->pid, &res, 0);
|
||||
myself->exit (res, 1);
|
||||
break;
|
||||
case _P_WAIT:
|
||||
|
Reference in New Issue
Block a user