public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: /proc/<PID>/status: simplify code generating signal info Date: Mon, 9 Jan 2023 17:03:34 +0000 (GMT) [thread overview] Message-ID: <20230109170334.50D0E3858D20@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9ee1e1b693ad7785e07f126ec725279fe605d621 commit 9ee1e1b693ad7785e07f126ec725279fe605d621 Author: Corinna Vinschen <corinna@vinschen.de> AuthorDate: Mon Jan 9 18:02:14 2023 +0100 Commit: Corinna Vinschen <corinna@vinschen.de> CommitDate: Mon Jan 9 18:02:14 2023 +0100 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: 9a3c058f6612 ("Cygwin: /proc/<PID>/status: Fill SigPnd, SigBlk and SigIgn values with life") Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- winsup/cygwin/pinfo.cc | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 586a4204d1db..ff10d9cf8c87 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -603,6 +603,19 @@ _pinfo::alive () 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 commune_process (void *arg) { @@ -679,13 +692,7 @@ commune_process (void *arg) case PICOM_SIGINFO: { sigproc_printf ("processing PICOM_SIGINFO"); - commune_result cr; - 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); + commune_result cr = commune_process_siginfo (); if (!WritePipeOverlapped (tothem, &cr, sizeof cr, &nr, 1000L)) sigproc_printf ("WritePipeOverlapped siginfo failed, %E"); break; @@ -1026,24 +1033,17 @@ _pinfo::root (size_t& n) int _pinfo::siginfo (sigset_t &pnd, sigset_t &blk, sigset_t &ign) { + commune_result cr; + if (!pid) return -1; if (pid != myself->pid && !ISSTATE (this, PID_NOTCYGWIN)) - { - commune_result cr = commune_request (PICOM_SIGINFO); - pnd = cr.pnd; - blk = cr.blk; - ign = cr.ign; - } + cr = commune_request (PICOM_SIGINFO); else - { - pnd = sig_send (myself, __SIGPENDINGALL, NULL); - blk = cygheap->compute_sigblkmask (); - ign = 0; - for (int sig = 1; sig < NSIG; ++sig) - if (global_sigs[sig].sa_handler == SIG_IGN) - ign |= SIGTOMASK (sig); - } + cr = commune_process_siginfo (); + pnd = cr.pnd; + blk = cr.blk; + ign = cr.ign; return -1; }
reply other threads:[~2023-01-09 17:03 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230109170334.50D0E3858D20@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).