Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15518
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Isaac To <isaac.to@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Signal ignore flags unexpectedly reset after "trap ... EXIT" |
| Date | Fri, 18 Oct 2019 22:49:32 +0800 |
| Lines | 167 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.1105.1571410194.9715.bug-bash@gnu.org> (permalink) |
| References | <CAOArY3X4VXAkmoCh0vsRZuHsJpw=jOF4_uLocsap1bG+QpK1iQ@mail.gmail.com> <CAOArY3WqmFFT4K4J2uzaEuS3ZcdZ69fwWV5Yj0WcHfr5TAm_qQ@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| X-Trace | usenet.stanford.edu 1571410195 2213 209.51.188.17 (18 Oct 2019 14:49:55 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=f11Pqchn+lLvSow8XAcTAKomIhN9whybNv3bJG0XiX4=; b=K8LXMsSdQyM4aoS+8xNJY+9FRawcJdvNFeg4EI8jWOE6cxjuC9WUerJcxcxnDBf29M h7o7P7gHAuDZ080kihvae6TcqrMi2DBzGH0s8Z3pzEAxXXD/ljO/I8WzE9UaZ4a4rMiC 1YXL9NzRpVkQCvM8r6Vd0/GUIFB7RgWwPWq0i4N5Oh6ArgF2yX2B4M9PMOdZ+wYC7qSq 1gGZRzbyCv7qmyxI2/hhQ2JDOg7lmWkY0kI4mK8XMcaxLdjVJm2qJMCK9EN/+qscBTnG Sfzp0xZ+vEigS+hFj1ynjTZIb+uW4LKFK64xWdADVZhf84g/Ld3Eiu11KJcBlbv/sGgF 5xhg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=f11Pqchn+lLvSow8XAcTAKomIhN9whybNv3bJG0XiX4=; b=SEadUBYZemlOKmI9zvIBiXOHnXGyhVLd8caPqlI5j7POxoG/T3IfstAI0/o9CVRLpz +U2d3fb8IZms+yVet9hSvHqcWbNOgyiTbpJfiftKL0V+Ht/jwHMRTrY9Q5zQN7T774tJ IxRTz1uLK6P4WSPdudOA79fKjNEmwrA9Y2D+tKgd88w/JINonuSWKW2M+rCGcDIsvaKH tdgT1CJjWjZzDuXRxLp9AhRCUeugVjii4d4K2KmQ0gOg3ORPidbdALSRB7zVa1dtmeNw 6VdzYw1PL4L3cOCnAt//YEDWp2SSzHwbeDcaUNLJb4EPNnDuqP7q3r/3gRk8Qrl1+u/k vFUw== |
| X-Gm-Message-State | APjAAAVvJadQRZ2YDl2O6iAz/4lPVRh+402TJG8aZcI78MHHFuXLVR8V 7uM9IjLjdO0sLrOZRgrfgsejQXpAXGh3D/4o9DXZcyWp |
| X-Google-Smtp-Source | APXvYqxLQBzk0Rvo73wUzU1mz8lK/kQOY/BbhmCbilMpJGc4uc1xTWZryBecedRtt6oJbUwPpSbBdiydgJ/fDu4csP8= |
| X-Received | by 2002:a9d:628b:: with SMTP id x11mr5421371otk.9.1571410183783; Fri, 18 Oct 2019 07:49:43 -0700 (PDT) |
| In-Reply-To | <CAOArY3X4VXAkmoCh0vsRZuHsJpw=jOF4_uLocsap1bG+QpK1iQ@mail.gmail.com> |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2607:f8b0:4864:20::342 |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.23 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <https://lists.gnu.org/archive/html/bug-bash> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAOArY3WqmFFT4K4J2uzaEuS3ZcdZ69fwWV5Yj0WcHfr5TAm_qQ@mail.gmail.com> |
| X-Mailman-Original-References | <CAOArY3X4VXAkmoCh0vsRZuHsJpw=jOF4_uLocsap1bG+QpK1iQ@mail.gmail.com> |
| Xref | csiph.com gnu.bash.bug:15518 |
Show key headers only | View raw
Dear Chet, I read your reply in the mailing list archive. Thanks a lot for the explanation, I get much better ideas about what the shell wants to do for me after reading it. Sorry that I have to reply to my own message rather than yours. I'll subscribe to the mailing list to ensure that this is not needed any more. Reading your response carefully I think you get most of the things you say you didn't get. For others, I want to add one comment: > trap '' USR1 > > grep SigIgn /proc/$BASHPID/status > > Presumably this reflects it; I don't know how to interpret the output. > This is a bitmask containing ignored signals, where signal n is represented by value (1 << (n - 1)). The 200 is signal 10, i.e., USR1. Then I want to explain what I consider a bug: > ( > > echo subshell $BASHPID > > grep SigIgn /proc/$BASHPID/status > > After setting all the caught signals back to SIG_DFL, this shell, call it > pid 811, sets SIGUSR1 to SIG_IGN, since that is the disposition it had when > its parent was started. This happens before pretty much anything else. > ... > Let's say this process has pid 813. In this subshell, there shouldn't be > any ignored signals after the shell initializes (it's interactive), but it > does this lazily. > If it should be set to SIG_DFL once anything about signals have to be done, why it even attempt to reset it to SIG_IGN after the subshell initialize? And, I cannot say that bringing an ignored signal back alive in the name of "exit handling" is a "correct behavior"... > I get exactly the same results in bash-4.4 running on RHEL7. > I'd like to confirm your results: when I run it once again in my Ubuntu 18 with bash 4.4 I see the same results. After reading your messages I can do simpler checks of the behaviour. First, I test 3 different versions of bash by running: - A: Ubuntu 19.04, bash 5.0.3(1)-release - B: Debian 4.9.189-3, bash 4.4.12(1)-release (Same results on 4.4.20 of Ubuntu 18.04.3) - C: CentOS Linux release 7.7.1908, bash 4.2.46(2)-release Here are the tests: $ trap '' USR1 $ (trap true EXIT; grep Ign /proc/$BASHPID/status) I see: A: SigIgn: 0000000000000200 B: SigIgn: 0000000000000200 C: SigIgn: 0000000000000200 So it is not that within subshells of interactive shells, once you trap EXIT you get the signal handler reset. In all the above cases it didn't happen. Then I test it by running: $ trap '' USR1 $ (trap true EXIT; (grep Ign /proc/$BASHPID/status) ) For this, I get: A: SigIgn: 0000000000000200 B: SigIgn: 0000000000000200 C: SigIgn: 0000000000000000 This is the actual reason why I have my complex test case in the previous mail: in my deployment there is an error, and I go back to a convenient machine running like (C) and try to reproduce it. I suddenly end up with something that causes an error. Then here is what is inspired by your reply: $ trap '' USR1 $ bash $ (trap true EXIT; grep Ign /proc/$BASHPID/status) For this: A: SigIgn: 0000000000000000 B: SigIgn: 0000000000000000 C: SigIgn: 0000000000000200 This is the behaviour I was reporting. The thing is, the behaviour is undocumented, and even if you want to document it you don't know how to do so. On Tue, Oct 15, 2019 at 5:22 PM Isaac To <isaac.to@gmail.com> wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -g -O2 > -fdebug-prefix-map=/build/bash-LQgi2O/bash-5.0=. -fstack-protector-strong > -Wformat -Werror=format-security -Wall -Wno-parentheses -Wno-format-security > uname output: Linux superposition 5.0.0-25-generic #26-Ubuntu SMP Thu Aug > 1 12:04:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux > Machine Type: x86_64-pc-linux-gnu > > Bash Version: 5.0 > Patch Level: 3 > Release Status: release > > Description: > > When trying to write a program and start it in an initrc script, I > observed a strange behavior: if a subshell is started by a subshell of that > script, and the inner subshell runs "trap ... EXIT", it unsets the signal > ignore flag of other signals. I'm not sure whether this should be called a > bug, or whether it is a problem caused by my own configuration. Anyway > here is how I reproduce my problem. > > Repeat-By: > > $ cat t.sh > echo t $BASHPID > trap '' USR1 > grep SigIgn /proc/$BASHPID/status > bash --rcfile t2.sh > $ cat t2.sh > echo t2 $BASHPID > grep SigIgn /proc/$BASHPID/status > ( > echo subshell $BASHPID > grep SigIgn /proc/$BASHPID/status > ( > echo subsubshell $BASHPID > grep SigIgn /proc/$BASHPID/status > echo trap $BASHPID > trap 'echo hello' EXIT > grep SigIgn /proc/$BASHPID/status > ) > ) > $ ./t.sh > t 15141 > SigIgn: 0000000000000204 > t2 15143 > SigIgn: 0000000000380004 > subshell 15145 > SigIgn: 0000000000000200 > subsubshell 15147 > SigIgn: 0000000000000200 > trap 15147 > SigIgn: 0000000000000000 > hello > $ > > Note that the final SigIgn flag is completely reset, which is what I won't > expect. The same problem won't occur if --rcfile is not used in t.sh. And > the problem also didn't show up in bash 4.4. > >
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Signal ignore flags unexpectedly reset after "trap ... EXIT" Isaac To <isaac.to@gmail.com> - 2019-10-18 22:49 +0800
csiph-web