php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9043 popen returns a 'Resource id #' (non null) when process cannot be created.
Submitted: 2001-02-01 00:16 UTC Modified: 2001-03-06 06:51 UTC
From: sah at uow dot edu dot au Assigned:
Status: Closed Package: *Directory/Filesystem functions
PHP Version: 4.0.3pl1 OS: Solaris 8
Private report: No CVE-ID: None
 [2001-02-01 00:16 UTC] sah at uow dot edu dot au
<?

$cp = popen('/bin/I_DO_NOT_EXIST', 'w');

echo "Result is $cp<br>\n";

?>


Returns the following:

Result is Resource id #1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-01 13:48 UTC] bbonev@php.net
confirmed on linux both php4.0.3pl1 and latest CVS
 [2001-03-06 06:51 UTC] stas@php.net
popen runs "sh -c <your command>". This command does
succeed. The fact that sh was unable to run your command
should be checked by the pclose status. 
Moreover, popen is pretty dangerous to use in PHP, since all
the I/O is buffered, and if the program exits before all the
output was written, you can easily get a SIGPIPE which will
kill your script.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 06:01:28 2024 UTC