#38796 [Opn->Bgs]: Self-call __destructor from child process
| From: | tony2001@php.net | Date: | Tue, 12 Sep 2006 18:39:54 +0000 |
| Subject: | #38796 [Opn->Bgs]: Self-call __destructor from child process | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-102061@lists.php.net to get a copy of this message | ||
ID: 38796
Updated by: tony2001@php.net
Reported By: fiw at mail dot ru
-Status: Open
+Status: Bogus
Bug Type: PCNTL related
Operating System: FreeBSD 6.1
PHP Version: 5.1.6
New Comment:
.
Previous Comments:
------------------------------------------------------------------------
[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