note 49643 deleted from function.register-shutdown-function by crell
| From: | crell@php.net | Date: | Thu, 31 Mar 2022 17:01:58 +0000 |
| Subject: | note 49643 deleted from function.register-shutdown-function by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217853@lists.php.net to get a copy of this message | ||
Note Submitter: codeslinger at compsalot dot com
----
Here is a nice little surprise to keep in mind...
If you register a shutdown function for your main program. And then you fork() a child.
Guess What?
When the child exits it will run the code that was intended for the main program. This can be a
really bad thing ;-)
Happily there is a simple work-around. All you need to do is to create a global variable such as:
$IamaChild = [TRUE | FALSE];
and have your shutdown function check the value...