note 119718 added to function.popen

From: Date: Wed, 10 Aug 2016 07:20:59 +0000
Subject: note 119718 added to function.popen
Groups: php.notes 
Request: Send a blank email to php-notes+get-206252@lists.php.net to get a copy of this message
Don't expect this function to return false when the executable doesn't exist in the first place. A stream will be opened anyway but nothing can be read from it. An error similar to "sh: 1: asdfasdfasdf: not found" will be printed to STDERR. Solution 1: Look at the return value of pclose(), it will be the exit status of the shell that runs the command. On Linux it will be 127 if the executable wasn't found. Otherwise it's the exit status of the executable itself. Solution 2: Use proc_open() instead, which allows to also capture STDERR and then parse it for errors. You probably should do both. ---- Server IP: 72.52.91.14 Probable Submitter: 85.195.255.242 ---- Manual Page -- http://php.net/manual/en/function.popen.php Edit -- https://master.php.net/note/edit/119718 Del: integrated -- https://master.php.net/note/delete/119718/integrated Del: useless -- https://master.php.net/note/delete/119718/useless Del: bad code -- https://master.php.net/note/delete/119718/bad+code Del: spam -- https://master.php.net/note/delete/119718/spam Del: non-english -- https://master.php.net/note/delete/119718/non-english Del: in docs -- https://master.php.net/note/delete/119718/in+docs Del: other reasons-- https://master.php.net/note/delete/119718 Reject -- https://master.php.net/note/reject/119718 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206252) next »