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>
This commit is contained in:
parent
28970dae34
commit
5a6de512ab
|
@ -37,7 +37,7 @@ enum child_status
|
||||||
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
#define EXEC_MAGIC_SIZE sizeof(child_info)
|
||||||
|
|
||||||
/* Change this value if you get a message indicating that it is out-of-sync. */
|
/* Change this value if you get a message indicating that it is out-of-sync. */
|
||||||
#define CURR_CHILD_INFO_MAGIC 0xecc930b9U
|
#define CURR_CHILD_INFO_MAGIC 0xacbf4682U
|
||||||
|
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
struct cchildren
|
struct cchildren
|
||||||
|
@ -71,6 +71,8 @@ public:
|
||||||
unsigned fhandler_union_cb;
|
unsigned fhandler_union_cb;
|
||||||
DWORD exit_code; // process exit code
|
DWORD exit_code; // process exit code
|
||||||
static int retry_count;// retry count;
|
static int retry_count;// retry count;
|
||||||
|
sigset_t sigmask;
|
||||||
|
|
||||||
child_info (unsigned, child_info_types, bool);
|
child_info (unsigned, child_info_types, bool);
|
||||||
child_info (): subproc_ready (NULL), parent (NULL) {}
|
child_info (): subproc_ready (NULL), parent (NULL) {}
|
||||||
~child_info ();
|
~child_info ();
|
||||||
|
@ -130,7 +132,6 @@ public:
|
||||||
int envc;
|
int envc;
|
||||||
char **envp;
|
char **envp;
|
||||||
HANDLE myself_pinfo;
|
HANDLE myself_pinfo;
|
||||||
sigset_t sigmask;
|
|
||||||
int nchildren;
|
int nchildren;
|
||||||
cchildren children[0];
|
cchildren children[0];
|
||||||
static cygheap_exec_info *alloc ();
|
static cygheap_exec_info *alloc ();
|
||||||
|
|
|
@ -845,7 +845,7 @@ dll_crt0_1 (void *)
|
||||||
_my_tls.incyg++;
|
_my_tls.incyg++;
|
||||||
/* Inherit "parent" exec'ed process sigmask */
|
/* Inherit "parent" exec'ed process sigmask */
|
||||||
if (spawn_info && !in_forkee)
|
if (spawn_info && !in_forkee)
|
||||||
_my_tls.sigmask = spawn_info->moreinfo->sigmask;
|
_my_tls.sigmask = spawn_info->sigmask;
|
||||||
|
|
||||||
if (dynamically_loaded)
|
if (dynamically_loaded)
|
||||||
sigproc_init ();
|
sigproc_init ();
|
||||||
|
|
|
@ -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),
|
msv_count (0), cb (in_cb), intro (PROC_MAGIC_GENERIC),
|
||||||
magic (CHILD_INFO_MAGIC), type (chtype), cygheap (::cygheap),
|
magic (CHILD_INFO_MAGIC), type (chtype), cygheap (::cygheap),
|
||||||
cygheap_max (::cygheap_max), flag (0), retry (child_info::retry_count),
|
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);
|
fhandler_union_cb = sizeof (fhandler_union);
|
||||||
user_h = cygwin_user_h;
|
user_h = cygwin_user_h;
|
||||||
|
@ -902,7 +902,6 @@ cygheap_exec_info::alloc ()
|
||||||
sizeof (cygheap_exec_info)
|
sizeof (cygheap_exec_info)
|
||||||
+ (chld_procs.count ()
|
+ (chld_procs.count ()
|
||||||
* sizeof (children[0])));
|
* sizeof (children[0])));
|
||||||
res->sigmask = _my_tls.sigmask;
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,9 +1352,20 @@ wait_sig (VOID *)
|
||||||
threadlist_t *tl_entry;
|
threadlist_t *tl_entry;
|
||||||
if (!pack.mask)
|
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);
|
tl_entry = cygheap->find_tls (_main_tls);
|
||||||
|
if (tl_entry)
|
||||||
|
{
|
||||||
dummy_mask = _main_tls->sigmask;
|
dummy_mask = _main_tls->sigmask;
|
||||||
cygheap->unlock_tls (tl_entry);
|
cygheap->unlock_tls (tl_entry);
|
||||||
|
}
|
||||||
|
else if (child_proc_info)
|
||||||
|
dummy_mask = child_proc_info->sigmask;
|
||||||
|
else
|
||||||
|
dummy_mask = 0;
|
||||||
pack.mask = &dummy_mask;
|
pack.mask = &dummy_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue