Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: "close" failing

by jdhedden (Deacon)
on May 31, 2006 at 16:00 UTC ( [id://552844]=note: print w/replies, xml ) Need Help??


in reply to "close" failing

The close command returns the exit status of the piped command.

If the piped command has exited with status=0 before close is called, then close will succeed.

If it exits with status != 0 before close is called, then close will fail and $? will equal the exit status.

If close is called before the piped command exits, then close will fail and $? will equal SIGPIPE. Why? Because Perl sends SIGPIPE to the piped command, then waits for it to exit, and then grabs its exit status which is the signal caught by the piped command (i.e., SIGPIPE). (Note that it is possible for the piped command to intercept the SIGPIPE signal and exit with some other exit status (e.g., exit 0) which will be picked up instead.)

In the case you experienced with the web server, it may be that the CGI is getting to the close command before the piped command actually exits. If you insist on testing the status of the close command, then modify your piped command to intercept SIGPIPE and terminate with a 0 exit status.


Remember: There's always one more bug.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://552844]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-19 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found