in reply to problem with redirection and piping

It's because when you execute a piped chain of programs, the last program in the chain will receive the signal.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"
  • Comment on Re: problem with redirection and piping

Replies are listed 'Best First'.
Re^2: problem with redirection and piping
by ikegami (Patriarch) on Jan 10, 2010 at 08:34 UTC

    You seem to be implying that only the last command receives the signal, but that's not true. We know the Perl script received the signal since we can observe the signal handler sending output to STDERR.

    I presume what is happening is that the signal is sent to both perl and tee, and that tee exits before reading the text sent by perl in response to the signal.

    If you do kill -INT 1234 where 1234 is perl's pid, tee won't receive the signal, so it will log the text perl outputs from the signal handler.

      excellent, you are right. By sending the INT using PID it works as expected. Great, thats why you people were rocking. Thanks a lot and tons...