Problem with broken pipe/SIGPIPE 
Author Message
 Problem with broken pipe/SIGPIPE

When trying to write to a pipe whose read handle has been closed,
the write command is not returning an indication of any error, and
the script terminates.  With perl 4.0.10 (patchlevel 10), there is
no message, and the exit status is 141.  With perl 4.0.34, there is
a "Broken pipe" message, but there is no return from the write
command, and the script also terminates with exit status 141.
I'm running 4.0.10 on ConvexOS, and 4.0.34 on HP/UX.

Shouldn't the write command detect an error, and allow a return?

Typically, trying to write in this situation should result in the
signal SIGPIPE being generated, and as long as this signal is either
being ignored, or being caught and we return from the handler, the
write system call should return with an error, and errno set to EPIPE.
The perl write command doesn't seem to be detecting this.  What am I
missing?  Short of writing a handler for SIGPIPE, is there anything I
can do?  Is there a handler pre-defined for SIGPIPE?

Thanks for any pointers.  I've included the test script I'm using.

-steve

----- snip -----
#!/usr/bin/perl

pipe(RD, WT);
select(WT);
$| = 1;
select(STDOUT);

print(WT "1 line of junk to WT\n") || print "cannot write line 1\n";
$foo = <RD>;
print "from RD: $foo";

close(RD);

# I expect a return from this print command, to detect the error.
print(WT "2 line of junk to WT\n") || print "cannot write line 1\n";
$foo = <RD>;
print "from RD: $foo";

exit(0);
----- pins -----
--
  Steven Grotten                                CONVEX Computer Corporation
  SPP Development Software Test                      3000 Waterview Parkway

  phone: 214/497-4045



Mon, 28 Apr 1997 07:27:45 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem with broken pipe/SIGPIPE

2. when pipe writer ignores SIGPIPE and other signals...

3. Broken Pipe piping to sendmail

4. Problem with an unexpected "broken pipe"

5. SIGPIPE problems w/socket

6. SIGPIPE problem with Solaris?

7. re-using a filehandle after a broken pipe

8. Pipes: What causd es them to break?

9. Broken Pipe...

10. UNIX domain socket - Broken Pipe.

11. Broken pipes error

12. Broken Pipe

 

 
Powered by phpBB® Forum Software