diff options
author | Christopher Faylor <me@cgf.cx> | 2005-09-23 23:37:52 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2005-09-23 23:37:52 +0000 |
commit | 5e477e9a9b0bf9597f8f9a829edfe554ee97b140 (patch) | |
tree | 3de620f8769d15f51065ea593c5b12381bcf3714 /winsup | |
parent | 1b19d7429605f4879186aa3eb0214e2c22bc4530 (diff) | |
download | newlib-5e477e9a9b0bf9597f8f9a829edfe554ee97b140.zip newlib-5e477e9a9b0bf9597f8f9a829edfe554ee97b140.tar.gz newlib-5e477e9a9b0bf9597f8f9a829edfe554ee97b140.tar.bz2 |
Semi-reversion of always-exit-from-sigthread change of 2005-09-15.
* exceptions.cc (sigpacket::process): Eliminate return after call to reinstated
noreturn function.
(signal_exit): Allow function to exit when a captive process has been
terminated.
* pinfo.cc (pinfo::exit): Enter exit_lock here. Once again exit here under
control of exit_lock.
* sigproc.cc (sig_send): Don't wait for completion if process is exiting.
Remove special __SIGEXIT accommodations.
(wait_sig): Just exit the thread when a __SIGEXIT has been detected. Don't
exit the process.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 14 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 9 | ||||
-rw-r--r-- | winsup/cygwin/init.cc | 1 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 20 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 39 |
5 files changed, 26 insertions, 57 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a69681a..2f2a6fc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,19 @@ 2005-09-23 Christopher Faylor <cgf@timesys.com> + Semi-reversion of always-exit-from-sigthread change of 2005-09-15. + * exceptions.cc (sigpacket::process): Eliminate return after call to + reinstated noreturn function. + (signal_exit): Allow function to exit when a captive process has been + terminated. + * pinfo.cc (pinfo::exit): Enter exit_lock here. Once again exit here + under control of exit_lock. + * sigproc.cc (sig_send): Don't wait for completion if process is exiting. + Remove special __SIGEXIT accommodations. + (wait_sig): Just exit the thread when a __SIGEXIT has been detected. + Don't exit the process. + +2005-09-23 Christopher Faylor <cgf@timesys.com> + * net.cc (cygwin_gethostbyname): Remove debugging cruft. 2005-09-23 Christopher Faylor <cgf@timesys.com> diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 79cc251..c51dd0b 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -40,7 +40,7 @@ extern NO_COPY DWORD dwExeced; int NO_COPY sigExeced; static BOOL WINAPI ctrl_c_handler (DWORD); -static void signal_exit (int); +static void signal_exit (int) __attribute__ ((noreturn)); char windows_system_directory[1024]; static size_t windows_system_directory_length; @@ -1160,9 +1160,7 @@ exit_sig: si.si_signo |= 0x80; } sigproc_printf ("signal %d, about to call do_exit", si.si_signo); - signal_exit (si.si_signo); - /* May not return */ - return rc; + signal_exit (si.si_signo); /* never returns */ } CRITICAL_SECTION NO_COPY exit_lock; @@ -1177,11 +1175,10 @@ signal_exit (int rc) { sigproc_printf ("terminating captive process"); TerminateProcess (hExeced, sigExeced = rc); - return; } EnterCriticalSection (&exit_lock); - if (exit_already++) + if (hExeced || exit_state) myself.exit (rc); /* We'd like to stop the main thread from executing but when we do that it diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index cad51cc..b00b7fe 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -141,6 +141,7 @@ extern "C" int WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load) { BOOL is_wow64_proc = FALSE; + // _STRACE_ON; switch (reason) { diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 2a5f47c..e2e6218 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -151,31 +151,19 @@ pinfo::exit (DWORD n) } sigproc_terminate (ES_FINAL); + zap_cwd (); /* FIXME: There is a potential race between an execed process and its parent here. I hated to add a mutex just for that, though. */ struct rusage r; fill_rusage (&r, hMainProc); add_rusage (&self->rusage_self, &r); - - if (n != EXITCODE_NOSET) - { - zap_cwd (); - self->alert_parent (0); /* Shave a little time by telling our - parent that we have now exited. */ - } int exitcode = self->exitcode & 0xffff; if (!self->cygstarted) exitcode >>= 8; - - _my_tls.stacklock = 0; - _my_tls.stackptr = _my_tls.stack; - sigproc_printf ("Calling ExitThread hProcess %p, n %p, exitcode %p", - hProcess, n, exitcode); - if (&_my_tls == _sig_tls) - ExitProcess (exitcode); - else - ExitThread (exitcode); + release (); + sigproc_printf ("Calling ExitProcess n %p, exitcode %p", n, exitcode); + ExitProcess (exitcode); } # undef self diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 6bcb6bc..69c9bce 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -553,7 +553,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) } if (wait_sig_inited) wait_for_sigthread (); - wait_for_completion = p != myself_nowait && _my_tls.isinitialized (); + wait_for_completion = p != myself_nowait && _my_tls.isinitialized () && !exit_state; p = myself; } @@ -621,15 +621,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) pack.si.si_uid = myself->uid; pack.pid = myself->pid; pack.tls = (_cygtls *) tls; - if (si.si_signo == __SIGEXIT) - { - if (&_my_tls == _main_tls) - pack.thread_handle = hMainThread; - else - DuplicateHandle (hMainProc, GetCurrentThread (), hMainProc, &pack.thread_handle, 0, - FALSE, DUPLICATE_SAME_ACCESS); - } - else if (wait_for_completion) + if (wait_for_completion) { pack.wakeup = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL); sigproc_printf ("wakeup %p", pack.wakeup); @@ -1122,29 +1114,6 @@ wait_sig (VOID *self) break; } - my_sendsig = NULL; - HANDLE& h = pack.thread_handle; - if (!h) - api_fatal ("no thread handle set on exit"); - DWORD res = WaitForSingleObject (h, INFINITE); - - DWORD exitcode = 1; - - myself.release (); - if (res == WAIT_OBJECT_0) - { - GetExitCodeThread (h, &exitcode); -#ifdef DEBUGGING - hMainThread = INVALID_HANDLE_VALUE; -#endif - } else { -#ifdef DEBUGGING - console_printf ("wait for main thread %p returned %d", h, res); -#else - debug_printf ("wait for main thread %p returned %d", h, res); -#endif - } - - sigproc_printf ("calling ExitProcess, exitcode %p", exitcode); - ExitProcess (exitcode); + sigproc_printf ("signal thread exiting"); + ExitThread (0); } |