diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 274597238..7b65931ab 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2013-04-07 Christopher Faylor + + * cygheap.cc (init_cygheap::find_tls): Add a comment. + * dcrt0.cc (parent_sigmask): Delete. + (dll_crt0_1): Use spawn_info->moreinfo->sigmask rather than saved + parent signal mask. + * thread.cc (pthread::thread_init_wrapper): Add comment stressing the + importance of maintaining ordering of statements. + 2013-04-05 Corinna Vinschen * mmap.cc (is_mmapped_region): Call LIST_UNLOCK on premature return. diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index 7ac30122b..90873215b 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -628,6 +628,7 @@ init_cygheap::find_tls (int sig, bool& issig_wait) else { ix = -1; + /* Scan thread list looking for valid signal-delivery candidates */ while (++ix < (int) nthreads) if (!threadlist[ix]->tid) continue; diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index f7f7756a2..c2684dee7 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -398,7 +398,6 @@ check_sanity_and_sync (per_process *p) } child_info NO_COPY *child_proc_info; -static NO_COPY sigset_t parent_sigmask; #define CYGWIN_GUARD (PAGE_READWRITE | PAGE_GUARD) @@ -655,8 +654,6 @@ child_info_spawn::handle_spawn () FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE)) h = NULL; - parent_sigmask = moreinfo->sigmask; - /* Setup our write end of the process pipe. Clear the one in the structure. The destructor should never be called for this but, it can't hurt to be safe. */ @@ -824,9 +821,9 @@ dll_crt0_1 (void *) extern void initial_setlocale (); _my_tls.incyg++; - if (!in_forkee) - _my_tls.sigmask = parent_sigmask; /* always zero if started by non-cygwin - process */ + /* Inherit "parent" exec'ed process sigmask */ + if (spawn_info && !in_forkee) + _my_tls.sigmask = spawn_info->moreinfo->sigmask; if (dynamically_loaded) sigproc_init (); diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 699b34479..183b9b8d5 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1912,6 +1912,9 @@ DWORD WINAPI pthread::thread_init_wrapper (void *arg) { pthread *thread = (pthread *) arg; + /* This *must* be set prior to calling set_tls_self_pointer or there is + a race with the signal processing code which may miss the signal mask + settings. */ _my_tls.sigmask = thread->parent_sigmask; thread->set_tls_self_pointer ();