CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate: Re: [FishMonger] send to a db and then to a script: Edit Log



7stud
Enthusiast

Mar 26, 2010, 10:19 AM


Views: 4396
Re: [FishMonger] send to a db and then to a script


Quote
# the result of this next line surprised me,
# which is why I also passed the string in the open call
say $pipe $str;

Is the parent or the child executing that statement? There is a difference between a 'pipe open' and a 'fork open'. You haven't handled the 'fork open' correctly. Even if you had, simpler is better, and a pipe open is all that is called for in the op's situation. I did overlook a problem with the 'pipe open' that needs to be handled--the case when the script being opened doesn't exist, which is particularly relevant here because the op's script doesn't actually exist due to path problems.

According to perlipc, when the script specified in the the 'pipe open' doesn't exist, the 'pipe open' will still succeed. Subsequently writing to the pipe will cause the cgi script to blow up when it receives a PIPE signal--which is sent to the cgi script when it tries to write to a pipe that has been closed. Closed pipe? But the 'pipe open' succeeded?! Yeah, but according to perlipc the fact that the 'pipe open' succeeded doesn't actually mean the pipe was ever opened. Confusing. The cgi script will only discover that the pipe wasn't opened successfully when the cgi script tries to write to the pipe.

Also of note is that the PIPE signal may only get sent to the cgi script after the cgi script calls close() on the pipe. Calling close() on the pipe causes the output buffer to be flushed, which then actually writes the output to the pipe.

To protect the cgi script from terminating due to a PIPE signal, you should add the following before the 'pipe open':


Code
$SIG{PIPE} = 'IGNORE';


However, I suspect that this is all beyond the op's comprehension.


(This post was edited by 7stud on Mar 26, 2010, 11:07 AM)


Edit Log:
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:22 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:23 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:27 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:28 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:47 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:52 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:54 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:55 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 10:57 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 11:07 AM
Post edited by 7stud (Enthusiast) on Mar 26, 2010, 11:07 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives