Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$| = 1;
$i = 0;
$SIG{'INT'} = 'handler_of_int';
sub handler_of_int {
print STDOUT "got END\n";
print STDERR "signal caught...\n";
close(stdout); exit(0);
}
while (1) {
print STDOUT ++$i;
sleep (1);
}
When i execute this way, and give CTRL+C ( sigint ), it prints the 'got END'.
perl write.pl 123^Cgot END signal caught...But when i execute this same program using tee command, the 'got END' is not getting printed either to file or to stdout. ( tee - read from standard input and write to standard output and files )
perl write.pl | tee file 12^Csignal caught...
cat file 12Whats wrong with this ?!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with redirection and piping
by Khen1950fx (Canon) on Jan 10, 2010 at 10:34 UTC | |
|
Re: problem with redirection and piping
by BrowserUk (Patriarch) on Jan 10, 2010 at 08:23 UTC | |
by ikegami (Patriarch) on Jan 10, 2010 at 08:34 UTC | |
by Anonymous Monk on Jan 10, 2010 at 13:04 UTC |