
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