0

From bash manual

Non-builtin commands started by Bash have signal handlers set to the values inherited by the shell from its parent.

When job control is not in eff ect, asynchronous commands ignore SIGINT and SIGQUIT in addition to these inherited handlers.

Commands run as a result of command substitution ignore the keyboard-generated job control signals SIGTTIN, SIGTTOU, and SIGTSTP.

I was wondering if someone could give some examples to show what the above mean? Thanks.

Related When typing ctrl-c in a terminal, why isn't the foreground job terminated until it completes?

1
stty tostop
echo bar >&2 & # no output from echo, just from shell job control
fg # now the output is produced
    bar
text=$(echo foo; echo bar >&2) # command substitution in foreground command
    bar
text=$(echo /etc/passwd; echo bar >&2) ; ls -l "$text" &
    bar
fg
    -rw-r--r-- 1 root root 2745 18. Feb 00:36 /etc/passwd

The "normal" output of the background command is delayed due to SIGTTOU but the output from the command substitution in the background to stderr is visible immediately.

external commands

trap '' HUP
bash
sleep 1234 # PID 23456

in a defferent shell

kill -HUP 23456 # does not abort sleep
  • Thanks. Can you also explain and give example for "Non-builtin commands started by Bash have signal handlers set to the values inherited by the shell from its parent"? – Tim May 27 '18 at 22:04
  • @Tim See the edit. – Hauke Laging May 27 '18 at 22:24
  • Thanks. Why does the quote mention "When job control is not in effect"? In your examples, is job control in effect or not? – Tim May 27 '18 at 23:15
  • @Tim My example is about SIGTTOU, not about job control. Thus that manual statement is not applicable here. – Hauke Laging May 28 '18 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.