Bug 84828

Summary: exit() does not report correct exit code
Product: [Retired] Red Hat Linux Reporter: Fred Wittekind <fredw>
Component: phpAssignee: Joe Orton <jorton>
Status: CLOSED ERRATA QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: byronc
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2003-07-03 11:46:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Fred Wittekind 2003-02-21 19:27:07 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)

Description of problem:
Call to exit() returns 255 instead of passed value

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1.Create test script (test.php)
2. # php -f test.php ; echo $?


Actual Results:  255

Expected Results:  1

Additional info:

Problem is fixed in php 4.2.3 stock source code.
Seems to be fixed by the following patch
(this patch is taken from a diff between 4.2.2 and 4.2.3)
--- php-4.2.2/sapi/cgi/cgi_main.c.orig  2003-02-21 13:42:28.000000000 -0500
+++ php-4.2.2/sapi/cgi/cgi_main.c       2003-02-21 13:53:20.000000000 -0500
@@ -775,11 +775,8 @@
                switch (behavior) {
                        case PHP_MODE_STANDARD:
-                               if (php_execute_script(&file_handle TSRMLS_CC)) 
-                                       exit_status = EG(exit_status);
-                               } else {
-                                       exit_status = 255;
-                               }
+                php_execute_script(&file_handle TSRMLS_CC);
+                exit_status = EG(exit_status);
                        case PHP_MODE_LINT:
                                PG(during_request_startup) = 0;

Comment 1 Joe Orton 2003-06-16 19:51:11 UTC
*** Bug 97490 has been marked as a duplicate of this bug. ***

Comment 2 Joe Orton 2003-06-16 19:52:24 UTC
Thanks for the report, and for tracking down the fix.  This change will be
incorporated for a forthcoming erratum.

Comment 3 Joe Orton 2003-07-03 11:46:47 UTC
An errata has been issued which should help the problem described in this bug report. 
This report is therefore being closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, please follow the link below. You may reopen 
this bug report if the solution does not work for you.