[php-src] Issue #22123: Exit in register_shutdown_function overwrites exit code since PHP8.4
| From: | PrinsFrank | Date: | Fri, 22 May 2026 11:43:44 +0000 |
| Subject: | [php-src] Issue #22123: Exit in register_shutdown_function overwrites exit code since PHP8.4 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-252116@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/22123
Author: PrinsFrank
### Description
The following code:
```php
<?php declare(strict_types=1);
register_shutdown_function(static function () {
exit; // prevent further shutdown handlers from being called
});
exit(1);
```
https://3v4l.org/C9oKE#v
Results in exit code
0 since PHP8.4, while it returned the original exit code
1 in previous versions.
According to [the
documentation](https://www.php.net/manual/en/function.register-shutdown-function.php), this is
should be a valid way to stop shutdown_function propagation:
> If you call [exit()](https://www.php.net/manual/en/function.exit.php) within one registered
> shutdown function, processing will stop completely and no other registered shutdown functions will
> be called.
### PHP Version
```plain
8.4.1 - 8.4.18, 8.5.0 - 8.5.3 (from above sample from 3v4l.org)
```
### Operating System
_No response_