#38796 [Fbk->Opn]: Self-call __destructor from child process
| From: | fiw at mail dot ru | Date: | Tue, 12 Sep 2006 19:16:18 +0000 |
| Subject: | #38796 [Fbk->Opn]: Self-call __destructor from child process | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-102065@lists.php.net to get a copy of this message | ||
ID: 38796
User updated by: fiw at mail dot ru
Reported By: fiw at mail dot ru
-Status: Feedback
+Status: Open
Bug Type: PCNTL related
Operating System: FreeBSD 6.1
PHP Version: 5.1.6
New Comment:
Sorry, I don't know english much well. But you can see this bug in
expected result - child process call not own destructors.
Previous Comments:
------------------------------------------------------------------------
[2006-09-12 19:08:14] tony2001@php.net
What do you want me to check?
Care to describe what's your problem with some more words.
------------------------------------------------------------------------
[2006-09-12 19:03:36] fiw at mail dot ru
I check this code on Cygwin with PHP 5.1.4 and have similar result.
------------------------------------------------------------------------
[2006-09-12 18:49:54] fiw at mail dot ru
Tony, it's real not bogus! Check it!
------------------------------------------------------------------------
[2006-09-12 18:39:54] tony2001@php.net
.
------------------------------------------------------------------------
[2006-09-12 18:28:49] fiw at mail dot ru
Description:
------------
No descriptions, sorry.
Reproduce code:
---------------
<?php
declare(ticks = 1);
class Daemon {
private $threads = array();
function __construct() {
echo posix_getpid() . ' Daemon::construct()' . "\n";
for ($i = 0; $i < 5; $i++) $threads[] = new Thread;
}
function __destruct() {
echo posix_getpid() . ' Daemon::destruct()' . "\n";
}
}
class Thread {
function __construct() {
echo posix_getpid() . ' Thread::construct()' . "\n";
$this->pid = pcntl_fork();
if ($this->pid == -1) throw new Exception;
if ($this->pid) {
pcntl_wait($status);
return;
}
echo posix_getpid() . ' Thread::child()' . "\n";
exit;
}
function __destruct() {
echo posix_getpid() . ' Thread::destruct()' . "\n";
}
}
new Daemon;
?>
Expected result:
----------------
77080 Daemon::construct()
77080 Thread::construct()
77081 Thread::child()
77081 Daemon::destruct()
77081 Thread::destruct()
77080 Thread::construct()
77082 Thread::child()
77082 Daemon::destruct()
77082 Thread::destruct()
77082 Thread::destruct()
77080 Thread::construct()
77083 Thread::child()
77083 Daemon::destruct()
77083 Thread::destruct()
77083 Thread::destruct()
77083 Thread::destruct()
77080 Thread::construct()
77084 Thread::child()
77084 Daemon::destruct()
77084 Thread::destruct()
77084 Thread::destruct()
77084 Thread::destruct()
77084 Thread::destruct()
77080 Thread::construct()
77085 Thread::child()
77085 Daemon::destruct()
77085 Thread::destruct()
77085 Thread::destruct()
77085 Thread::destruct()
77085 Thread::destruct()
77085 Thread::destruct()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Daemon::destruct()
Actual result:
--------------
77080 Daemon::construct()
77080 Thread::construct()
77081 Thread::child()
77080 Thread::construct()
77082 Thread::child()
77080 Thread::construct()
77083 Thread::child()
77080 Thread::construct()
77084 Thread::child()
77080 Thread::construct()
77085 Thread::child()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Thread::destruct()
77080 Daemon::destruct()
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38796&edit=1