Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status codes #7

Closed
wants to merge 1 commit into from
Closed

status codes #7

wants to merge 1 commit into from

Conversation

tvlooy
Copy link

@tvlooy tvlooy commented Oct 12, 2010

if you return a status code bigger than 255, bash will see it as status code 0. Proof:
$ php -r "exit(255);" ; echo $? 255
$ php -r "exit(256);" ; echo $? 0

This is also in the bash manpage in the section "EXIT STATUS". This fix makes sure an error code stays an error code (round it to 255, which means "error code out of range" by the way), so we can check for it. I noticed this because Doctrine 2.0 migrations threw a PDO exception and tried to exit with code 23000. This became an exit(0) and our buildsystem did a thumbs up. Obviously not ok :-)

@katanacrimson
Copy link

Taken from the PHP manual:

http://us3.php.net/manual/en/function.exit.php
If status is an integer, that value will be used as the exit status and not printed.
Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used.
The status 0 is used to terminate the program successfully.

The status code integer 255 should not be used at all according to the PHP documentation. While it looks like it can be used, they are asking that developers refrain from doing such.

@tvlooy
Copy link
Author

tvlooy commented Oct 13, 2010

Good point, thanks for bringing it up. Do you know the exact reason behind this? I grepped the php source but I can't really find where it is used. 255 seems to be the exit code (at the shell level) on some fatal errors, like failing require_once, or calling a non existing function. But, for example a parse error returns 254. Which seems strange.

Maybe it's better change it to exit(-1), which gets translated to 255 in bash too:
php -r "exit(-1);" ; echo $?
255

Suggestions? (ps: in the meantime, this was already committed upstream in Symfony, by Fabien)

@beberlei
Copy link
Member

This is an upstream bug, please report it with symfony

aldisanta pushed a commit to aldisanta/doctrine2 that referenced this pull request Oct 31, 2016
qkdreyer pushed a commit to qkdreyer/doctrine2 that referenced this pull request Jul 9, 2020
Kern046 pushed a commit to Kern046/doctrine-orm that referenced this pull request Apr 15, 2022
Fix codestyle with use statements for new XmlMapping tests
@tasselchof tasselchof mentioned this pull request Aug 2, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants