开发者

Php exec() return code is -1 when in a forked process, but 0 in a normal script

开发者 https://www.devze.com 2023-01-03 16:08 出处:网络
I am using exec() inside a a script that runs as a daemon and forks child processes using the pear class Net_Server.

I am using exec() inside a a script that runs as a daemon and forks child processes using the pear class Net_Server.

I am getting 开发者_开发知识库a strange issue whereby the return code (the third param of of exec) comes back as -1. When I run the command on the command line, or with exec in a normal php script the return code is 0 as it should be. Anyone have any idea why this is happening, and how to fix it?


 pcntl_signal(SIGCHLD, SIG_DFL);
 exec('...');
 pcntl_signal(SIGCHLD, 'whatever it was');


I guess it is an issue with environment variables. Maybe the thing you are trying to execute is normally in your PATH, but not when you spawn a daemon. Supply the full path to the program.

0

精彩评论

暂无评论...
验证码 换一张
取 消