#36187 [Opn->Bgs]: PHP-CLI does not return int exit status set by exit()
| From: | sniper@php.net | Date: | Sun, 29 Jan 2006 15:12:55 +0000 |
| Subject: | #36187 [Opn->Bgs]: PHP-CLI does not return int exit status set by exit() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-92597@lists.php.net to get a copy of this message | ||
ID: 36187
Updated by: sniper@php.net
Reported By: volker at puttrich dot net
-Status: Open
+Status: Bogus
Bug Type: CGI related
Operating System: Debian Sarge
PHP Version: 5.1.2
New Comment:
Works fine for me:
# php t.php ; echo $?
222
t.php:
<?php exit(222); ?>
Previous Comments:
------------------------------------------------------------------------
[2006-01-28 05:24:46] volker at puttrich dot net
Description:
------------
The CLI version of PHP does not return the integer exit status to the
shell when using 'exit(integer);' from within the script. PHP will
always return 0 (or 255 probably).
The manual says that it would do.
Calling 'exit("string");' (with a string as parameter) it works as
expected and as mentioned in the manual.
Reproduce code:
---------------
This is what I'm trying to do:
file1.php
---------
<?
system("php ./file2.php", $rv);
fwrite(STDOUT, $rv."\n");
system("php ./file2.php -- -param", $rv);
fwrite(STDOUT, $rv."\n");
?>
file2.php
---------
<?
if($argc < 2)
exit(1);
else
exit(0);
?>
Expected result:
----------------
Execute:
# php ./file1.php
Output should be:
1
0
Actual result:
--------------
Buggy result is:
0
0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36187&edit=1