From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 50D0E3858D20; Mon, 9 Jan 2023 17:03:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50D0E3858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673283814; bh=Uocw6xhKW4XT1BonSH+/OLzTVHOOYHsTyXsnGD25k48=; h=From:To:Subject:Date:From; b=Pl+q5laTp36aENrOxKLLOaon/j2IoPAJIqclYcmieN+TlatTiy1aVyMQuD3zSLXxM /UNt/N5PYqjM0QeEdAv0t8hAirb2GPLbNhibUa8T6wV1ykpQymkHF61PKJddOS6pQR 24yWVBaklrqULDlpYKTvdATcaFrPAgcS7kq5bfEg= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: /proc//status: simplify code generating signal info X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 7886327fbf92e6ad8bd3f27ea9fa8bd54cc44bdd X-Git-Newrev: 9ee1e1b693ad7785e07f126ec725279fe605d621 Message-Id: <20230109170334.50D0E3858D20@sourceware.org> Date: Mon, 9 Jan 2023 17:03:34 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D9ee1e1b693a= d7785e07f126ec725279fe605d621 commit 9ee1e1b693ad7785e07f126ec725279fe605d621 Author: Corinna Vinschen AuthorDate: Mon Jan 9 18:02:14 2023 +0100 Commit: Corinna Vinschen CommitDate: Mon Jan 9 18:02:14 2023 +0100 Cygwin: /proc//status: simplify code generating signal info =20 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. =20 Fixes: 9a3c058f6612 ("Cygwin: /proc//status: Fill SigPnd, SigBlk a= nd SigIgn values with life") Signed-off-by: Corinna Vinschen 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; } =20 +static commune_result +commune_process_siginfo () +{ + commune_result res =3D { 0 }; + + res.pnd =3D sig_send (myself, __SIGPENDINGALL, NULL); + res.blk =3D cygheap->compute_sigblkmask (); + for (int sig =3D 1; sig < NSIG; ++sig) + if (global_sigs[sig].sa_handler =3D=3D SIG_IGN) + res.ign |=3D 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 =3D sig_send (myself, __SIGPENDINGALL, NULL); - cr.blk =3D cygheap->compute_sigblkmask (); - for (int sig =3D 1; sig < NSIG; ++sig) - if (global_sigs[sig].sa_handler =3D=3D SIG_IGN) - cr.ign |=3D SIGTOMASK (sig); + commune_result cr =3D 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 !=3D myself->pid && !ISSTATE (this, PID_NOTCYGWIN)) - { - commune_result cr =3D commune_request (PICOM_SIGINFO); - pnd =3D cr.pnd; - blk =3D cr.blk; - ign =3D cr.ign; - } + cr =3D commune_request (PICOM_SIGINFO); else - { - pnd =3D sig_send (myself, __SIGPENDINGALL, NULL); - blk =3D cygheap->compute_sigblkmask (); - ign =3D 0; - for (int sig =3D 1; sig < NSIG; ++sig) - if (global_sigs[sig].sa_handler =3D=3D SIG_IGN) - ign |=3D SIGTOMASK (sig); - } + cr =3D commune_process_siginfo (); + pnd =3D cr.pnd; + blk =3D cr.blk; + ign =3D cr.ign; return -1; }