Skip to content

Fix GH-15796: Add the exit_status() function #19445

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexandre-daubois
Copy link
Member

Fix #15796

Especially useful in shutdown handler, allows to get the current exit status code if set by an exit statement.

Copy link
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation LGTM, but given this is a feature, I've requested reviews from the RMs.

@@ -41,6 +41,8 @@ function strncasecmp(string $string1, string $string2, int $length): int {}

function error_reporting(?int $error_level = null): int {}

function exit_status(): int {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function exit_status(): int {}
function exit_status(): ?int {}

Would make more sense to indicate we are in shutdown process or not.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to get your comment. Where/when should this function return null?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When exit was not called yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When exit is not called yet, the return code of the process will be 0. Also, it can be changed to 255 when an uncaught exception occurs. Thus, I'm not sure this function should return null, because the process will always have an exit code, no matter what.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

evade exit_status overwrite by exit()
3 participants