* 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.
This commit is contained in:
Christopher Faylor
2004-12-23 14:57:08 +00:00
parent 3993374d4e
commit 4ee52924a6
9 changed files with 70 additions and 34 deletions

View File

@ -38,8 +38,6 @@ details. */
#define WSSC 60000 // Wait for signal completion
#define WPSP 40000 // Wait for proc_subproc mutex
#define PSIZE 63 // Number of processes
#define no_signals_available() (!hwait_sig || (myself->sendsig == INVALID_HANDLE_VALUE) || exit_state)
#define NPROCS 256
@ -246,7 +244,9 @@ proc_subproc (DWORD what, DWORD val)
set_errno (EAGAIN);
break;
}
/* fall through intentionally */
case PROC_DETACHED_CHILD:
if (vchild != myself)
{
vchild->ppid = myself->pid;
@ -258,6 +258,8 @@ proc_subproc (DWORD what, DWORD val)
vchild->cygstarted = true;
vchild->process_state |= PID_INITIALIZING | (myself->process_state & PID_USETTY);
}
if (what == PROC_DETACHED_CHILD)
break;
procs[nprocs] = vchild;
rc = procs[nprocs].wait ();
if (rc)