On Mon, Sep 30, 2024 at 14:08:19 +0300, Anssi Saari wrote:
> Tim Woodall <debianu...@woodall.me.uk> writes:
> 
> > However on trying to debug something else, I wanted to run it like this:
> >
> > ./script |& tee log
> >
> > and now it doesn't clean up if I <ctrl c> it.
> 
> Just a point here about tee since I didn't see anyone else mention
> it. tee has had the -i option to ignore interrupt signals for ages. The
> non-obvious side effect is INT signals pass up the pipe, in your case to
> bash running your script.

Signals don't "pass up the pipe".  A process either receives a signal,
or it doesn't.

Using kill(2) or the shell's kill command to send a signal to a process
only sends the signal to *one* process, unless you use one of the
features to send signals to a group of processes (e.g. kill() with a
non-positive argument).

Pressing Ctrl-C (or whatever intr is bound to) in a terminal sends the
SIGINT to all of the "foreground" processes.  If you're running a shell
script as a foreground job in a terminal, and that shell script is running
some external foreground command, then keyboard Ctrl-C will send SIGINT
to the external foreground command *and* to the shell.

Reply via email to