|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17558 pcntl_signal() does not call user-defined function handler
Submitted: 2002-06-01 23:27 UTC Modified: 2002-09-09 01:00 UTC
Avg. Score:4.5 ± 0.5
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:1 (25.0%)
From: clay at killersoft dot com Assigned:
Status: No Feedback Package: *Extensibility Functions
PHP Version: 4.2.1 OS: Mac OS X
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: clay at killersoft dot com
New email:
PHP Version: OS:


 [2002-06-01 23:27 UTC] clay at killersoft dot com
function: pcntl_signal()

problem: If "handler" argument is set to a user-defined 
function, that function is never called.

script: (taken from

// signal handler function
function sig_handler($signo) {
	echo "We hit the sig_handler!\n";
     switch($signo) {
         case SIGTERM:
             // handle shutdown tasks
         case SIGHUP:
             // handle restart tasks
         case 1:
         	print "Caught sig 1 ...\n";
         case SIGUSR1:
             print "Caught SIGUSR1...\n";
             // handle all other signals


print "Installing signal handler...\n";

// setup signal handlers
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
pcntl_signal(SIGUSR1, "sig_handler");

print "Generating signal SIGTERM to self...\n";

// send SIGUSR1 to current process id
posix_kill(posix_getpid(), SIGUSR1);

print "Done\n"


The "we hit the sig handler!" echo never appears ... thus I 
suspect it's never being called.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-07 21:00 UTC]
Does this happen with the latest snapshot:

 [2002-08-07 02:22 UTC] jeff at tmtrading dot com
See bug id 15125.  Looks like a similar problem.
 [2002-08-08 00:51 UTC]
is pnctl built into php, or as a module - ?

 [2002-09-09 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-10-25 07:45 UTC] vlcc69jfbo001 at sneakemail dot com
I've been seeing the same thing, but on OpenBSD 3.1-stable.
I can't test with 4.3.0-cvs as it's currently broken for me 
(bug 20063), but my last build that worked (from about 5 
days ago) has this same problem - I set up signal handlers, 
send it signals and nothing happens.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 12:01:31 2024 UTC