Bug #60509 [Opn->Csd]: pcntl_signal doesn't decrease ref-count of old handler when setting SIG_DFL
Edit report at https://bugs.php.net/bug.php?id=60509&edit=1
ID: 60509
Updated by: jpauli@php.net
Reported by: mplomer at gmx dot de
Summary: pcntl_signal doesn't decrease ref-count of old
handler when setting SIG_DFL
-Status: Open
+Status: Closed
Type: Bug
Package: PCNTL related
Operating System: Debian Squeeze
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of jpauli
Revision: http://git.php.net/?p=php-src.git;a=commit;h=19b5bc8ce22b1476eb084a8b64c137bb8b17d674
Log: Fix #60509, pcntl_signal doesn't decrease ref-count of old handler
Previous Comments:
------------------------------------------------------------------------
[2011-12-13 09:30:35] mplomer at gmx dot de
Description:
------------
When overwriting an old signal handler (that references "$this" for example) with SIG_DFL,
the reference counter on $this is not decreased, so when unsetting the object, it cannot be freed.
My current workaround: When overwriting the signal handler with an empty function before
("function() {}"), the ref-count is correctly decreased (WTF?!), and the instance is
immediately freed, when unsetting the object.
Test script:
---------------
class Test {
public function __construct() {
pcntl_signal(SIGUSR1, array($this, 'signalHandler'), false);
//pcntl_signal(SIGUSR1, function() {}); // destruct works correctly when commenting in
pcntl_signal(SIGUSR1, SIG_DFL);
}
public function signalHandler() {
}
public function __destruct() {
echo '__destruct' . PHP_EOL;
}
}
$test = new Test();
echo 'unsetting' . PHP_EOL;
unset($test);
echo 'end' . PHP_EOL;
Expected result:
----------------
unsetting
__destruct
end
Actual result:
--------------
unsetting
end
__destruct
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60509&edit=1
Thread (5 messages)