Cygwin: /proc/<PID>/status: simplify code generating signal info
The code generating the signal info in _pinfo::siginfo() and in
commune_process() are doing the same thing. Create a local static
function commune_process_siginfo() to have the code in one place
only. Remove a useless sigpending() call.
Fixes: 9a3c058f66
("Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
7886327fbf
commit
9ee1e1b693
|
@ -603,6 +603,19 @@ _pinfo::alive ()
|
||||||
return !!h;
|
return !!h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static commune_result
|
||||||
|
commune_process_siginfo ()
|
||||||
|
{
|
||||||
|
commune_result res = { 0 };
|
||||||
|
|
||||||
|
res.pnd = sig_send (myself, __SIGPENDINGALL, NULL);
|
||||||
|
res.blk = cygheap->compute_sigblkmask ();
|
||||||
|
for (int sig = 1; sig < NSIG; ++sig)
|
||||||
|
if (global_sigs[sig].sa_handler == SIG_IGN)
|
||||||
|
res.ign |= SIGTOMASK (sig);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
commune_process (void *arg)
|
commune_process (void *arg)
|
||||||
{
|
{
|
||||||
|
@ -679,13 +692,7 @@ commune_process (void *arg)
|
||||||
case PICOM_SIGINFO:
|
case PICOM_SIGINFO:
|
||||||
{
|
{
|
||||||
sigproc_printf ("processing PICOM_SIGINFO");
|
sigproc_printf ("processing PICOM_SIGINFO");
|
||||||
commune_result cr;
|
commune_result cr = commune_process_siginfo ();
|
||||||
sigpending (&cr.pnd);
|
|
||||||
cr.pnd = sig_send (myself, __SIGPENDINGALL, NULL);
|
|
||||||
cr.blk = cygheap->compute_sigblkmask ();
|
|
||||||
for (int sig = 1; sig < NSIG; ++sig)
|
|
||||||
if (global_sigs[sig].sa_handler == SIG_IGN)
|
|
||||||
cr.ign |= SIGTOMASK (sig);
|
|
||||||
if (!WritePipeOverlapped (tothem, &cr, sizeof cr, &nr, 1000L))
|
if (!WritePipeOverlapped (tothem, &cr, sizeof cr, &nr, 1000L))
|
||||||
sigproc_printf ("WritePipeOverlapped siginfo failed, %E");
|
sigproc_printf ("WritePipeOverlapped siginfo failed, %E");
|
||||||
break;
|
break;
|
||||||
|
@ -1026,24 +1033,17 @@ _pinfo::root (size_t& n)
|
||||||
int
|
int
|
||||||
_pinfo::siginfo (sigset_t &pnd, sigset_t &blk, sigset_t &ign)
|
_pinfo::siginfo (sigset_t &pnd, sigset_t &blk, sigset_t &ign)
|
||||||
{
|
{
|
||||||
|
commune_result cr;
|
||||||
|
|
||||||
if (!pid)
|
if (!pid)
|
||||||
return -1;
|
return -1;
|
||||||
if (pid != myself->pid && !ISSTATE (this, PID_NOTCYGWIN))
|
if (pid != myself->pid && !ISSTATE (this, PID_NOTCYGWIN))
|
||||||
{
|
cr = commune_request (PICOM_SIGINFO);
|
||||||
commune_result cr = commune_request (PICOM_SIGINFO);
|
|
||||||
pnd = cr.pnd;
|
|
||||||
blk = cr.blk;
|
|
||||||
ign = cr.ign;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
cr = commune_process_siginfo ();
|
||||||
pnd = sig_send (myself, __SIGPENDINGALL, NULL);
|
pnd = cr.pnd;
|
||||||
blk = cygheap->compute_sigblkmask ();
|
blk = cr.blk;
|
||||||
ign = 0;
|
ign = cr.ign;
|
||||||
for (int sig = 1; sig < NSIG; ++sig)
|
|
||||||
if (global_sigs[sig].sa_handler == SIG_IGN)
|
|
||||||
ign |= SIGTOMASK (sig);
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue