Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    Because of the "&" it is not running "in" the script, but in background, and that may be the reason. Commented May 31, 2021 at 6:30
  • 1
    Observations: (1) set +m seems very relevant. Try with set -m and compare. (2) In my Debian the phenomenon does not occur in posh; this shell does not support set -m/set +m. Commented May 31, 2021 at 6:34
  • I confirm that with dash -m, sleep exits upon receiving SIGINT, as expected. I'm reading your answer now, and pondering how a child process can inherit a signal handler across an exec(). I was not aware that was possible. Commented May 31, 2021 at 6:52
  • @mpb A signal handler doesn't persist across exec(), but the ignored/not-ignored status does. More precisely, if a signal has a handler, exec() resets it to the default action, which is to kill the process for many but not all signals (e.g. SIGTSTP, SIGCONT). Commented May 31, 2021 at 15:46