diff options
author | Christopher Faylor <me@cgf.cx> | 2002-12-25 20:33:21 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-12-25 20:33:21 +0000 |
commit | 088f471c7534c4bd1a363a87463a2e2adf05297e (patch) | |
tree | 4a4e83e1dae8b5af79f6f39b2d638d1b8c19a838 /winsup/cygwin | |
parent | a8eb76e3e157b0531d82ed1b0f4dc57de235c275 (diff) | |
download | cygnal-088f471c7534c4bd1a363a87463a2e2adf05297e.tar.gz cygnal-088f471c7534c4bd1a363a87463a2e2adf05297e.tar.bz2 cygnal-088f471c7534c4bd1a363a87463a2e2adf05297e.zip |
* exceptions.cc (events_init): Initialize critical section to control exiting
via signal.
(signal_exit): Enter critical section early to avoid exit races with main
thread.
* dcrt0.cc (do_exit): Use exit_lock critical section to avoid races.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 8 | ||||
-rw-r--r-- | winsup/cygwin/dcrt0.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/exceptions.cc | 4 |
3 files changed, 14 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 81ad7d148..f4248c3b2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,13 @@ 2002-12-25 Christopher Faylor <cgf@redhat.com> + * exceptions.cc (events_init): Initialize critical section to control + exiting via signal. + (signal_exit): Enter critical section early to avoid exit races with + main thread. + * dcrt0.cc (do_exit): Use exit_lock critical section to avoid races. + +2002-12-25 Christopher Faylor <cgf@redhat.com> + * cygthread.cc (cygthread::detach): Set errno with set_sig_errno so that EINTR is properly restored after signal. diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index f12654d26..da39f07a1 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -967,10 +967,12 @@ enum exit_states }; exit_states NO_COPY exit_state; +extern CRITICAL_SECTION exit_lock; extern "C" void __stdcall do_exit (int status) { + EnterCriticalSection (&exit_lock); UINT n = (UINT) status; syscall_printf ("do_exit (%d)", n); diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index bbd5518d0..dc59dc5a4 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1088,12 +1088,15 @@ sig_handle (int sig, bool thisproc) /* Never returns */ } +CRITICAL_SECTION NO_COPY exit_lock; + /* Cover function to `do_exit' to handle exiting even in presence of more exceptions. We used to call exit, but a SIGSEGV shouldn't cause atexit routines to run. */ static void signal_exit (int rc) { + EnterCriticalSection (&exit_lock); rc = EXIT_SIGNAL | (rc << 8); if (exit_already++) myself->exit (rc); @@ -1149,6 +1152,7 @@ events_init (void) debug_printf ("windows_system_directory '%s', windows_system_directory_length %d", windows_system_directory, windows_system_directory_length); debug_printf ("cygwin_hmodule %p", cygwin_hmodule); + InitializeCriticalSection (&exit_lock); } void |