diff options
author | Christopher Faylor <me@cgf.cx> | 2013-01-14 06:03:59 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2013-01-14 06:03:59 +0000 |
commit | b712b4408ac6364121d9478af4ac82290ce4b72a (patch) | |
tree | b6c75257dc3628d919b4ed66625d0262130ef2e3 | |
parent | cdc1925e021287aca3be485ad1059ce3e244e2c1 (diff) | |
download | newlib-b712b4408ac6364121d9478af4ac82290ce4b72a.zip newlib-b712b4408ac6364121d9478af4ac82290ce4b72a.tar.gz newlib-b712b4408ac6364121d9478af4ac82290ce4b72a.tar.bz2 |
* exceptions.cc (signal_exit): Move captive process termintation...
(_cygtls::interrupt_setup): ...into here.
(sigpacket::process): Simplify setting of handler when have_execed.
(_cygtls::interrupt_setup): Don't call proc_subproc when we've execed.
* globals.cc (exit_states): Delete unneeded ES_EXEC_EXIT.
* pinfo.cc (pinfo::exit): Change debugging output. Call proc_terminate rather
than the now-obsolete sigproc_terminate. Don't set exit_state to ES_EXEC_EXIT.
Set exit_state to ES_FINAL later.
* sigproc.cc (sigproc_terminate): Delete function.
(wait_sig): Don't call proc_subproc if have_execed.
* sigproc.h (sigproc_terminate): Delete declaration.
* sync.h (lock_process::lock_process): Don't set exit_state to
ES_PROCESS_LOCKED.
(lock_process::operator LONG): Define.
-rw-r--r-- | winsup/cygwin/ChangeLog | 17 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 18 | ||||
-rw-r--r-- | winsup/cygwin/globals.cc | 1 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 10 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 17 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/sync.h | 3 |
7 files changed, 31 insertions, 38 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 57a8216..7c8d34a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,20 @@ +2013-01-14 Christopher Faylor <me.cygwin2013@cgf.cx> + + * exceptions.cc (signal_exit): Move captive process termintation... + (_cygtls::interrupt_setup): ...into here. + (sigpacket::process): Simplify setting of handler when have_execed. + (_cygtls::interrupt_setup): Don't call proc_subproc when we've execed. + * globals.cc (exit_states): Delete unneeded ES_EXEC_EXIT. + * pinfo.cc (pinfo::exit): Change debugging output. Call proc_terminate + rather than the now-obsolete sigproc_terminate. Don't set exit_state + to ES_EXEC_EXIT. Set exit_state to ES_FINAL later. + * sigproc.cc (sigproc_terminate): Delete function. + (wait_sig): Don't call proc_subproc if have_execed. + * sigproc.h (sigproc_terminate): Delete declaration. + * sync.h (lock_process::lock_process): Don't set exit_state to + ES_PROCESS_LOCKED. + (lock_process::operator LONG): Define. + 2013-01-11 Christopher Faylor <me.cygwin2013@cgf.cx> * DevNotes: Add entry cgf-000021. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 669b174..c8bf6d2 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -764,7 +764,8 @@ _cygtls::interrupt_setup (siginfo_t& si, void *handler, struct sigaction& siga) if (incyg) SetEvent (get_signal_arrived (false)); - proc_subproc (PROC_CLEARWAIT, 1); + if (!have_execed) + proc_subproc (PROC_CLEARWAIT, 1); sigproc_printf ("armed signal_arrived %p, signal %d", signal_arrived, si.si_signo); } @@ -1089,12 +1090,6 @@ signal_exit (int sig, siginfo_t *si) debug_printf ("exiting due to signal %d", sig); exit_state = ES_SIGNAL_EXIT; - if (have_execed) - { - sigproc_printf ("terminating captive process"); - TerminateProcess (ch_spawn, sigExeced = sig); - } - if (cygheap->rlim_core > 0UL) switch (sig) { @@ -1186,9 +1181,7 @@ sigpacket::process () sigproc_printf ("using tls %p", tls); } - void *handler = (void *) thissig.sa_handler; - if (have_execed) - handler = NULL; + void *handler = have_execed ? NULL : (void *) thissig.sa_handler; if (handler == SIG_IGN) { @@ -1271,6 +1264,11 @@ dispatch_sig: if we hit an exception. */ _my_tls.signal_debugger (si.si_signo); } + if (have_execed) + { + sigproc_printf ("terminating captive process"); + TerminateProcess (ch_spawn, sigExeced = si.si_signo); + } /* Dispatch to the appropriate function. */ sigproc_printf ("signal %d, signal handler %p", si.si_signo, handler); rc = setup_handler (handler, thissig, tls); diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc index 581aecb..adcfa8c 100644 --- a/winsup/cygwin/globals.cc +++ b/winsup/cygwin/globals.cc @@ -43,7 +43,6 @@ enum exit_states ES_THREADTERM, ES_HUP_PGRP, ES_HUP_SID, - ES_EXEC_EXIT, ES_TTY_TERMINATE, ES_FINAL }; diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 6bd0513..ba7b2da 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -175,18 +175,16 @@ pinfo::maybe_set_exit_code_from_windows () void pinfo::exit (DWORD n) { - minimal_printf ("winpid %d, exit %d", GetCurrentProcessId (), n); - sigproc_terminate (ES_FINAL); + debug_only_printf ("winpid %d, exit %d", GetCurrentProcessId (), n); + proc_terminate (); lock_process until_exit (true); cygthread::terminate (); if (n != EXITCODE_NOSET) self->exitcode = EXITCODE_SET | n;/* We're really exiting. Record the UNIX exit code. */ else - { - exit_state = ES_EXEC_EXIT; - maybe_set_exit_code_from_windows (); - } + maybe_set_exit_code_from_windows (); /* may block */ + exit_state = ES_FINAL; if (myself->ctty > 0 && !iscons_dev (myself->ctty)) { diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index f0498ad..b38abc3 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -467,21 +467,6 @@ sigproc_init () new cygthread (wait_sig, cygself, "sig"); } -/* Called on process termination to terminate signal and process threads. - */ -void __stdcall -sigproc_terminate (exit_states es) -{ - exit_states prior_exit_state = exit_state; - exit_state = es; - if (!cygwin_finished_initializing) - /* nothing to do */; - else if (prior_exit_state >= ES_FINAL) - sigproc_printf ("already performed"); - else - proc_terminate (); // clean up process stuff -} - /* Exit the current thread very carefully. See cgf-000017 in DevNotes for more details on why this is necessary. */ @@ -1427,7 +1412,7 @@ wait_sig (VOID *) } break; } - if (clearwait) + if (clearwait && !have_execed) proc_subproc (PROC_CLEARWAIT, 0); loop: if (pack.wakeup) diff --git a/winsup/cygwin/sigproc.h b/winsup/cygwin/sigproc.h index 1da19da..8fd17c9 100644 --- a/winsup/cygwin/sigproc.h +++ b/winsup/cygwin/sigproc.h @@ -76,9 +76,6 @@ int __stdcall proc_subproc (DWORD, DWORD) __attribute__ ((regparm (2))); class _pinfo; void __stdcall proc_terminate (); void __stdcall sigproc_init (); -#ifdef __INSIDE_CYGWIN__ -void __stdcall sigproc_terminate (enum exit_states); -#endif bool __stdcall pid_exists (pid_t) __attribute__ ((regparm(1))); int __stdcall sig_send (_pinfo *, siginfo_t&, class _cygtls * = NULL) __attribute__ ((regparm (3))); int __stdcall sig_send (_pinfo *, int, class _cygtls * = NULL) __attribute__ ((regparm (3))); diff --git a/winsup/cygwin/sync.h b/winsup/cygwin/sync.h index 5c6bc4b..7d3c794 100644 --- a/winsup/cygwin/sync.h +++ b/winsup/cygwin/sync.h @@ -52,8 +52,6 @@ public: { locker.acquire (); skip_unlock = exiting; - if (exiting && exit_state < ES_PROCESS_LOCKED) - exit_state = ES_PROCESS_LOCKED; } void release () { @@ -65,6 +63,7 @@ public: if (!skip_unlock) release (); } + operator LONG () const {return locker.visits; } static void force_release (_cygtls *tid) {locker.release (tid);} friend class dtable; friend class fhandler_fifo; |