help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why are pipeline commands (allowed to be) executed in subshells?


From: Philippe Cerfon
Subject: Re: why are pipeline commands (allowed to be) executed in subshells?
Date: Tue, 13 Dec 2022 04:39:14 +0100

Any I have one moreā€¦ why does this work (tried both interactively,
non-interactively):
1) run a script:
trap "echo HUP called" HUP
sleep 1000 &
wait $!

2) send HUP to the bash that runs this script

This causes it to immediately print the string exit.

In the example given in my previous mail (without the wait) the shell
did not pass on the HUP signal to forground sleep (where it was
waiting), so its HUP trap neither got executed.

In this example now, HUP neither makes it to the sleep process (at
least according to strace) but the shell also doesn't wait at the
sleep, but at the wait.

Wait seems to be classified as utility (despite it's built-in). So if
the shell dosen't pass on the HUP to sleep, shouldn't the wait remain
waiting until the sleep is gone and only afterwards the handler for
HUP be called?


Thanks,
Philippe.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]