+2012-03-19 Christopher Faylor <me.cygwin2012@cgf.cx>
+
+ * pinfo.cc (pinfo_init): Cosmetic change: unset "destroy" for myself.
+ (pinfo::wait): Change some comments.
+ (pinfo::prefork): Move a comment.
+ (pinfo::postfork): Set pending_*_pipe variables to NULL if closed.
+ (pinfo::postexec): Use right name when closing handle.
+ (_pinfo::alert_parent): Ditto.
+ * sigproc.h (hold_everything): Remove debugging label.
+
2012-03-19 Christopher Faylor <me.cygwin2012@cgf.cx>
* cygserver_ipc.h: Include sigproc.h for signal_arrived declaration.
myself->process_state |= PID_ACTIVE;
myself->process_state &= ~(PID_INITIALIZING | PID_EXITED | PID_REAPED);
+ myself.preserve ();
debug_printf ("pid %d, pgid %d", myself->pid, myself->pgid);
}
case __ALERT_ALIVE:
continue;
case 0:
+debug_printf ("%d exited buf %d\n", vchild->pid, buf);
/* Child exited. Do some cleanup and signal myself. */
vchild.maybe_set_exit_code_from_windows ();
if (WIFEXITED (vchild->exitcode))
bool
pinfo::wait ()
{
+ /* If pending_rd_proc_pipe == NULL we're in an execed process which has
+ already grabbed the read end of the pipe from the previous cygwin process
+ running with this pid. */
if (pending_rd_proc_pipe)
{
+ /* Our end of the pipe, previously set in prefork() . */
rd_proc_pipe = pending_rd_proc_pipe;
pending_rd_proc_pipe = NULL;
+ /* This sets wr_proc_pipe in the child which, after the following
+ ForceCloseHandle1, will be only process with the handle open. */
wr_proc_pipe () = pending_wr_proc_pipe;
ForceCloseHandle1 (pending_wr_proc_pipe, wr_proc_pipe);
pending_wr_proc_pipe = NULL;
if (wr_proc_pipe () && wr_proc_pipe () != INVALID_HANDLE_VALUE
&& !SetHandleInformation (wr_proc_pipe (), HANDLE_FLAG_INHERIT, 0))
api_fatal ("couldn't set process pipe(%p) inherit state, %E", wr_proc_pipe ());
- /* If rd_proc_pipe != NULL we're in an execed process which already has
- grabbed the read end of the pipe from the previous cygwin process running
- with this pid. */
if (!detached)
{
if (!CreatePipe (&pending_rd_proc_pipe, &pending_wr_proc_pipe,
HANDLE_FLAG_INHERIT))
api_fatal ("postfork: couldn't set process pipe(%p) inherit state, %E", wr_proc_pipe ());
if (pending_rd_proc_pipe)
- ForceCloseHandle1 (pending_rd_proc_pipe, rd_proc_pipe);
+ {
+ ForceCloseHandle1 (pending_rd_proc_pipe, rd_proc_pipe);
+ pending_rd_proc_pipe = NULL;
+ }
if (pending_wr_proc_pipe)
- ForceCloseHandle1 (pending_wr_proc_pipe, wr_proc_pipe);
+ {
+ ForceCloseHandle1 (pending_wr_proc_pipe, wr_proc_pipe);
+ pending_wr_proc_pipe = NULL;
+ }
}
void
pinfo::postexec ()
{
if (wr_proc_pipe () && wr_proc_pipe () != INVALID_HANDLE_VALUE
- && !ForceCloseHandle (wr_proc_pipe ()))
+ && !ForceCloseHandle1 (wr_proc_pipe (), wr_proc_pipe))
api_fatal ("postexec: couldn't close wr_proc_pipe(%p), %E", wr_proc_pipe ());
}
ppid = 1;
HANDLE closeit = wr_proc_pipe;
wr_proc_pipe = INVALID_HANDLE_VALUE;
- CloseHandle (closeit);
+ ForceCloseHandle1 (closeit, wr_proc_pipe);
}
}
return (bool) nb;