summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/pinfo.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2004-12-23 14:57:08 +0000
committerChristopher Faylor <me@cgf.cx>2004-12-23 14:57:08 +0000
commit4ee52924a61bdb2fd8ce7b64d111cf7df4d19fe3 (patch)
tree18464135531157edc28ecc4f73a7210511638611 /winsup/cygwin/pinfo.cc
parent3993374d4ee8a081056fad98ebed90975970ccee (diff)
downloadcygnal-4ee52924a61bdb2fd8ce7b64d111cf7df4d19fe3.tar.gz
cygnal-4ee52924a61bdb2fd8ce7b64d111cf7df4d19fe3.tar.bz2
cygnal-4ee52924a61bdb2fd8ce7b64d111cf7df4d19fe3.zip
* cygthread.cc (cygthread::stub): Detect if thread function wants to release
itself here, to avoid a race. (cygthread::release): Clear more stuff. Add a diagnostic for an internal error. * cygthread.h (auto_release): New function. * pinfo.h (pinfo::remember): Add an argument to denote whether child is detached. * fork.cc (fork_parent): Reflect change in arguments to pinfo::remember. * pinfo.cc (_pinfo::exit): Signal exit more forcibly. (proc_waiter): Use cygthread::auto_release to signify that cygthread::stub should release the thread. This should avoid a race. (pinfo::alert_parent): Don't signify an error when wr_proc_pipe == NULL. * sigproc.cc (proc_subproc): Add support for PROC_DETACHED_CHILD. * sigproc.h: Ditto. * spawn.cc (spawn_guts): Specify whether child is detached or not when calling pinfo::remember.
Diffstat (limited to 'winsup/cygwin/pinfo.cc')
-rw-r--r--winsup/cygwin/pinfo.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index af0b893b0..ec51c8530 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -135,8 +135,8 @@ _pinfo::exit (UINT n, bool norecord)
/* We could just let this happen automatically when the process
exits but this should gain us a microsecond or so by notifying
the parent early. */
- if (wr_proc_pipe)
- CloseHandle (wr_proc_pipe);
+ myself.alert_parent (0);
+
}
}
@@ -764,7 +764,7 @@ proc_waiter (void *arg)
sigproc_printf ("exiting wait thread for pid %d", pid);
vchild.wait_thread = NULL;
- _my_tls._ctinfo->release (false); /* return the cygthread to the cygthread pool */
+ _my_tls._ctinfo->auto_release (); /* automatically return the cygthread to the cygthread pool */
return 0;
}
@@ -816,10 +816,10 @@ pinfo::alert_parent (char sig)
DWORD nb = 0;
/* Send something to our parent. If the parent has gone away,
close the pipe. */
- if (myself->wr_proc_pipe == INVALID_HANDLE_VALUE)
+ if (myself->wr_proc_pipe == INVALID_HANDLE_VALUE
+ || !myself->wr_proc_pipe)
/* no parent */;
- else if (myself->wr_proc_pipe
- && WriteFile (myself->wr_proc_pipe, &sig, 1, &nb, NULL))
+ else if (WriteFile (myself->wr_proc_pipe, &sig, 1, &nb, NULL))
/* all is well */;
else if (GetLastError () != ERROR_BROKEN_PIPE)
debug_printf ("sending %d notification to parent failed, %E", sig);