-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[console] Exit code should not be capped, but masked #13996
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
Comments
Ref #8202 http://www.php.net/manual/en/function.exit.php
So in php terms we would need to mask with 254 which would also not be consistent with linux. |
@Tobion It's been a while I found a practical use for bit-operations, but if I remember correctly masking with |
It seems that a simple php script:
actually outputs 44 as well (strace shows Maybe it would even be better to not handle these situations after all, and remove the cap all together without replacing it with a mask? |
@jaytaph If PHP is doing the right thing for us, let's remove the logic on our side. |
@fabpot I think that is a good idea.. however, I do not know what will happen on windows machines. Maybe somebody should verify if this behaviour is the same? |
@jaytaph on windows it's not masked. The code below returns 300. So I guess the masking is done by the linux console and not by php because in mingw your example also outputs 44.
|
@Tobion The cap is actually done by the linux exit_group system call: http://lxr.free-electrons.com/source/kernel/exit.c#L842 Here is the exit code masked with Same exit result ( It seems that under windows, exit codes are 32-bit signed integers (http://en.wikipedia.org/wiki/Exit_status#Windows), so here no filtering should take place anyway (an Maybe we should thus get rid of the cap, and not even replace it with a mask? As every supported OS seems to handle this fine, and PHP doesn't really care either way (exit codes are passed directly to the OS), even the 255 reserved code seems to cause no issues (a quick scan through the php core doesn't even seem to suggest 255 should be considered reserved, maybe this is a remnant from past versions). |
Not capping has a severe issue: |
Closing it for the reasons given by @stof in the previous comment and @Tobion in #17591 (comment). |
Inside the console Application.php, an exit code is capped to 255 if it is larger than 255. This is in agreement with Linux where exit codes are only valid in the 0-255 range.
However, Linux by default (including most applications, like bash), do not cap, but mask the exit code with
& 255
instead. Accordingly, an application that exits with status code 300 will receive the exit code 44. In a symfony console application, this would be 255.Maybe this is something that might be changed as well in the application.php?
The text was updated successfully, but these errors were encountered: