Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > how to detect broken pipe ?

Reply
Thread Tools

how to detect broken pipe ?

 
 
funtoosh
Guest
Posts: n/a
 
      12-20-2003
Hi

Scenario:

I have a shell script e.g. a.bash
This script wraps a program called "generate" like this:

generate > /tmp/y.txt 2>&1 # both stdout and stderr r redirected to
y.txt

Now , I have perl script e.g. myPerl.pl and I modify a.bash such that:

generate | perl myPerl.pl # pipe output from "generate" to the perl
script.

And in myPerl.pl, I wrote this :

sub whatSignal { print "caught ",shift, "\n" };
$SIG($_}=\ &whatSignal for keys %SIG

And now I run a.bash in one xterm:
Following happens:
When press ctrl-C, it is caught.

But when I kill pid of program "generate" from a different xterm, my
script doesnt detect "broken pipe" ?

Comments ?
 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      12-21-2003

http://www.velocityreviews.com/forums/(E-Mail Removed) (funtoosh) wrote:
> generate | perl myPerl.pl # pipe output from "generate" to the perl
> script.
>
> And in myPerl.pl, I wrote this :
>
> sub whatSignal { print "caught ",shift, "\n" };
> $SIG($_}=\ &whatSignal for keys %SIG


You only get sent SIGPIPE when you write to a broken pipe. Reading
will simply return EOF.

This Is Not A Perl Question.

Ben

--
. | .
\ / The clueometer is reading zero.
. .
__ <-----@ __ (E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[named pipe] i wanna know about validate of pipe handle of client lee, wonsun C++ 1 11-02-2004 04:29 AM
How do I detect if I have incoming data in <STDIN> when I pipe somethingto my perl script ? Andreas Berg Perl Misc 11 08-07-2004 10:42 AM
Why does IO::Pipe::END generate an EXCEPT pipe message? lvirden@gmail.com Perl Misc 1 06-02-2004 02:17 PM
broken pipe error messages thrown by tomcat -- how to suppress? Clive Java 0 08-12-2003 01:42 PM
How do I detect if input is from a pipe or not? badbob Perl Misc 0 08-05-2003 07:49 PM



Advertisments