diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2022-05-03 16:16:18 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2022-05-03 16:16:18 +0300 |
commit | 5a6de512ab5d46f7a0f019e7345e800a0a274a62 (patch) | |
tree | 5a51a03bdeda43355f606b4f1e3032cbee09d0e7 /winsup/cygwin/sigproc.cc | |
parent | 28970dae34522059e094eb7db466404facb09460 (diff) |
Cygwin: always add sigmask to child info
Even after fork, we might need the parent sigmask without having
access to the real _main_tls. There's a short time at process startup,
when _main_tls points to the system-allocated stack, but wait_sig is
already running. If we can't lock _main_tls, because find_tls can't
find it yet, we now access the parent's sigmask via child_info.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/sigproc.cc')
-rw-r--r-- | winsup/cygwin/sigproc.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 62df96652..987dfea37 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -820,7 +820,7 @@ child_info::child_info (unsigned in_cb, child_info_types chtype, msv_count (0), cb (in_cb), intro (PROC_MAGIC_GENERIC), magic (CHILD_INFO_MAGIC), type (chtype), cygheap (::cygheap), cygheap_max (::cygheap_max), flag (0), retry (child_info::retry_count), - rd_proc_pipe (NULL), wr_proc_pipe (NULL) + rd_proc_pipe (NULL), wr_proc_pipe (NULL), sigmask (_my_tls.sigmask) { fhandler_union_cb = sizeof (fhandler_union); user_h = cygwin_user_h; @@ -902,7 +902,6 @@ cygheap_exec_info::alloc () sizeof (cygheap_exec_info) + (chld_procs.count () * sizeof (children[0]))); - res->sigmask = _my_tls.sigmask; return res; } @@ -1353,9 +1352,20 @@ wait_sig (VOID *) threadlist_t *tl_entry; if (!pack.mask) { + /* There's a short time at process startup of a forked process, + when _main_tls points to the system-allocated stack, not to + the parent thread. In that case find_tls fails, and we fetch + the sigmask from the child_info passed from the parent. */ tl_entry = cygheap->find_tls (_main_tls); - dummy_mask = _main_tls->sigmask; - cygheap->unlock_tls (tl_entry); + if (tl_entry) + { + dummy_mask = _main_tls->sigmask; + cygheap->unlock_tls (tl_entry); + } + else if (child_proc_info) + dummy_mask = child_proc_info->sigmask; + else + dummy_mask = 0; pack.mask = &dummy_mask; } |