php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38480 Signal handling simply does not work!
Submitted: 2006-08-17 09:42 UTC Modified: 2006-08-17 09:56 UTC
From: bh at ez dot no Assigned:
Status: Not a bug Package: PCNTL related
PHP Version: 5.1.4 OS: Debian Linux, Unstable
Private report: No CVE-ID: None
 [2006-08-17 09:42 UTC] bh at ez dot no
Description:
------------
PHP5-CLI: "pcntl_signal" is malfunctioning. It traps the desidred signal(s) but it does not execute the code which is in the custom signal handler! This is very annoying.

Reproduce code:
---------------
<?php

function whatever( $signal )
{
    echo( "Inside whatever, got $signal\n" );
}

pcntl_signal( SIGTERM, 'whatever' );
pcntl_signal( SIGUSR1, 'whatever' );

echo( 'My PID is: ' . getmypid() . "\n" );

// Hard-sleep for 30 secs.
time_sleep_until( microtime( true ) + 30 );

echo( "Bye.\n" );

?>


Expected result:
----------------
Start up the provided source code using PHP5-CLI, remember the PID that the script outputs and use "kill -15 <PID>" to send a SIGTERM to it.

The script should trap the signal, execute the custom signal handler code and thus output:

"Inside whatever, got 15"

However, this does not happen. Note that the signal is in fact CAUGHT, because if you remove the handler for SIGTERM and then send a signal 15 to the script, it will self-terminate.

Apparently none of the other signals work either (checked with SIGUSR1/2, etc.).


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Nov 29 12:03:14 2021 UTC