note 60108 added to function.register-shutdown-function
| From: | sezeryalcin at osu1 dot php dot net | Date: | Tue, 27 Dec 2005 05:11:06 +0000 |
| Subject: | note 60108 added to function.register-shutdown-function | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-100762@lists.php.net to get a copy of this message | ||
re:codeslinger at compsalot dot com
fork() is actually creating 2 processes from one. So there is no surprise register_shutdown_function
will be executed per each process.
I think you have reported this as a bug and now in php 5.1.0 when you exit from child process, it
does not execute it. Well, what are you going to do if you have something to register for forked
process?
I hope php will be more stable near soon!
codeslinger at compsalot dot com
03-Feb-2005 09:22
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...
----
Manual Page -- http://www.php.net/manual/en/function.register-shutdown-function.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+60108
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60108&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60108&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60108&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60108&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60108&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60108&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60108&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+60108&report=yes
Search -- http://master.php.net/manage/user-notes.php