in reply to forking, no child waiting.

Oh man,,,, I was all happy, and then I tried it, it worked great when running it from the prompt, but still just kind-of dies when done from the php app. I am hating this part! Here is where I am calling my perl script:

$run="snmp-wdr -c mrtgtest $request &"; echo "<BR>COMMAND SENT: $run<BR>"; $setsys=system($run);

DANG!
I am wondering if it has something to do with the mysql commands in the perl script, it appears that snmp-wdr IS running, and that is DOES start using snmp, but the mysql commands in the script are not functioning. Maybe that is why it works perfect from prompt, but not from web system()??

use hand while code!=$working bash $head

Replies are listed 'Best First'.
Re: Re: forking, no child waiting.
by kjherron (Pilgrim) on Sep 21, 2001 at 04:37 UTC
    It may be that PHP (or the web server) has set up a pipe between itself and the standard output of your script. If that's the case, then PHP (or the web server) won't think the page is finished until it gets end-of-file on that pipe. When you start a subprocess, it gets a copy of your script's stdout/stderr, which isn't released until the subprocess exits or explicitly closes those descriptors.

    Try closing stdout and stderr in the subprocess and see if it helps:

    $run="snmp-wdr -c mrtgtest $request > /dev/null 2>&1 &"; echo "<BR>COMMAND SENT: $run<BR>"; $setsys=system($run);