diff options
author | Christopher Faylor <me@cgf.cx> | 2004-02-13 22:34:32 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2004-02-13 22:34:32 +0300 |
commit | edc4f86ad282702ab7c029cf65b87ec616bda05e (patch) | |
tree | 2abde4171eaab1863d78128ba2ef6418485eff57 /winsup/cygwin/sigproc.cc | |
parent | b3535c273043da91247840c4af64bb573d5517c4 (diff) |
* Makefile.in (clean): Remove sigfe.s.
(sigfe.s): Ensure that sigfe.s will be regenerated if it does not exist.
* dll_init.cc (dll_dllcrt0): Simplify initializing tests.
* exceptions.cc (setup_handler): Detect when stub caller is either spinning or
has acquired the lock after being suspended to avoid windows problems with
suspending a win32 API call.
* cygtls.h (_cygtls::spinning): Declare new element.
* gendef: Remove unused _siglist_index and _siglist declaration.
(_sigfe): Set spinning element when potentially looping, waiting for lock.
(_sigbe): Ditto.
(_cygtls::lock): Ditto.
(_longjmp): Ditto.
* tlsoffsets.h: Regenerate.
* pinfo.cc (_pinfo::exit): Set final exit state here. Call sigproc_terminate
if invoked with 'norecord'. Clear any residual _cygtls stuff.
* winsup.h (exit_states): Define ES_FINAL.
* spawn.cc (spawn_guts): Don't call proc_terminate specifically when execing.
Let _pinfo::exit handle that case.
* sigproc.cc (wait_subproc): Always exit loop early when proc_loop_wait.
* init.cc (munge_threadfunc): Eliminate unused argument.
(dll_entry): Reflect above change in call to munge_threadfunc.
Diffstat (limited to 'winsup/cygwin/sigproc.cc')
-rw-r--r-- | winsup/cygwin/sigproc.cc | 62 |
1 files changed, 26 insertions, 36 deletions
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index c013e0d20..5d7e049be 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -70,26 +70,6 @@ static pending_signals sigqueue; struct sigaction *global_sigs; -void __stdcall -sigalloc () -{ - cygheap->sigs = global_sigs = - (struct sigaction *) ccalloc (HEAP_SIGS, NSIG, sizeof (struct sigaction)); -} - -void __stdcall -signal_fixup_after_exec () -{ - global_sigs = cygheap->sigs; - /* Set up child's signal handlers */ - for (int i = 0; i < NSIG; i++) - { - global_sigs[i].sa_mask = 0; - if (global_sigs[i].sa_handler != SIG_IGN) - global_sigs[i].sa_handler = SIG_DFL; - } -} - /* * Global variables */ @@ -101,19 +81,15 @@ char NO_COPY myself_nowait_dummy[1] = {'0'};// Flag to sig_send that signal goes HANDLE NO_COPY signal_arrived; // Event signaled when a signal has // resulted in a user-specified // function call -/* - * Common variables - */ +#define Static static NO_COPY /* How long to wait for message/signals. Normally this is infinite. - * On termination, however, these are set to zero as a flag to exit. - */ - -#define Static static NO_COPY + On termination, however, these are set to zero as a flag to exit. */ Static DWORD proc_loop_wait = 1000; // Wait for subprocesses to exit +Static HANDLE sendsig_tome; HANDLE NO_COPY sigCONT; // Used to "STOP" a process Static cygthread *hwait_sig; // Handle of wait_sig thread Static cygthread *hwait_subproc; // Handle of sig_subproc thread @@ -149,6 +125,26 @@ static DWORD WINAPI wait_sig (VOID *arg); static int __stdcall stopped_or_terminated (waitq *, _pinfo *); static DWORD WINAPI wait_subproc (VOID *); +void __stdcall +sigalloc () +{ + cygheap->sigs = global_sigs = + (struct sigaction *) ccalloc (HEAP_SIGS, NSIG, sizeof (struct sigaction)); +} + +void __stdcall +signal_fixup_after_exec () +{ + global_sigs = cygheap->sigs; + /* Set up child's signal handlers */ + for (int i = 0; i < NSIG; i++) + { + global_sigs[i].sa_mask = 0; + if (global_sigs[i].sa_handler != SIG_IGN) + global_sigs[i].sa_handler = SIG_DFL; + } +} + /* Determine if the parent process is alive. */ @@ -1215,17 +1211,13 @@ wait_subproc (VOID *) { DWORD rc = WaitForMultipleObjects (nchildren + 1, events, FALSE, proc_loop_wait); + if (!proc_loop_wait) + break; if (rc == WAIT_TIMEOUT) - if (!proc_loop_wait) - break; // Exiting - else - continue; + continue; if (rc == WAIT_FAILED) { - if (!proc_loop_wait) - break; - /* It's ok to get an ERROR_INVALID_HANDLE since another thread may have closed a handle in the children[] array. So, we try looping a couple of times to stabilize. FIXME - this is not foolproof. Probably, this @@ -1274,8 +1266,6 @@ wait_subproc (VOID *) si.si_stime = 0; #endif rc = proc_subproc (PROC_CHILDTERMINATED, rc); - if (!proc_loop_wait) // Don't bother if wait_subproc is - break; // exiting /* Send a SIGCHLD to myself. We do this here, rather than in proc_subproc to avoid the proc_subproc lock since the signal thread will eventually |