P is for Practical | |
PerlMonks |
Re: exec, echo and pipeby andal (Hermit) |
on Apr 01, 2016 at 07:20 UTC ( [id://1159251]=note: print w/replies, xml ) | Need Help?? |
I might be wrong, but using "exec" directly in CGI script is not very good idea. The "exec" simply replaces current binary with new binary, it does not terminate the process, so the Web server shall wait for this new binary to finish its work, and that might be undesirable. The appropriate way would be to do fork then exit the parent and do exec in the child. Ideally, the child should also call POSIX::setsid, to detach itself away from Web server, otherwise it could be killed by the server. Forking also makes possible to pass your password over the pipe. Something like the following could do the trick
The code above is not tested. Read more about processes groups and sessions to understand why the switch of session might be good.
In Section
Seekers of Perl Wisdom
|
|