note 57456 added to function.proc-open

From: Date: Tue, 04 Oct 2005 19:34:55 +0000
Subject: note 57456 added to function.proc-open
Groups: php.notes 
Request: Send a blank email to php-notes+get-96387@lists.php.net to get a copy of this message
One can learn from the source code in ext/standard/exec.c that the right-hand side of a descriptor assignment does not have to be an array ('file', 'pipe', or 'pty') - it can also be an existing open stream. <?php $p = proc_open('myfilter', array( 0 => $infile, ...), $pipes); ?> I was glad to learn that because it solves the race condition in a scenario like this: you get a file name, open the file, read a little to make sure it's OK to serve to this client, then rewind the file and pass it as input to the filter. Without this feature, you would be limited to <?php array('file', $fname) ?> or passing the name to the filter command. Those choices both involve a race (because the file will be reopened after you have checked it's OK), and the last one invites surprises if not carefully quoted, too. ---- Manual Page -- http://www.php.net/manual/en/function.proc-open.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57456 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57456&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57456&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57456&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57456&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57456&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57456&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57456&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57456&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#96387) next »