PHP passthru() blocks with bash process replacement?

From: Date: Mon, 05 Mar 2012 13:29:14 +0000
Subject: PHP passthru() blocks with bash process replacement?
Groups: php.general 
Request: Send a blank email to php-general+get-316882@lists.php.net to get a copy of this message
Hi all, I have a problem with PHP passthru() blocking when it is supposed to start a daemon and return. I have a Node.js daemon with a bash script wrapper around it. Users can call this bash script directly, but it is also used by our deployment system. Our deployment system uses Phing, and Phing uses exec() and passthru() internally to cann external programs. The bash script wrapper around my Node.js uses a bit of process replacement because my Node.js server can't directly log to syslog. Normally I'd start Node.js like this: forever -l app.log app.js But because I want it to log to syslog, I put this in the bash script: forever -l >(logger) app.js The logger process replacement creates a file descriptor into syslog like /dev/fd/63 whose path is passed to the forever command as the logfile to use. This works great when I start the daemon using the bash script directly, but when the bash script is executed using PHP passthru() or exec() then these calls will block. If I use a regular logfile instead of the process replacement then both passthru() and exec() work just fine, starting the daemon in the background. I have created a complete working example (using a simple PHP daemon instead of Node.js) on Github's Gist: https://gist.github.com/1977896 (needs PHP 5.3.6+) Why does the passthru() call block on the process replacement? And is there anything I can do to work around it? Kind regards, -- Sander Marechal

« previous php.general (#316882) next »