pcntl_signal() not work in PHP 7.0.8-0ubuntu0.16.04.2

Bug #1610964 reported by Evgeniy
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
php7.0 (Ubuntu)
Incomplete
Low
Nish Aravamudan

Bug Description

# lsb_release -rd
Description: Ubuntu 16.04.1 LTS
Release: 16.04

-------------------

# apt-cache policy php7.0
php7.0:
  Installed: (none)
  Candidate: 7.0.8-0ubuntu0.16.04.2
  Version table:
     7.0.8-0ubuntu0.16.04.2 500
        500 http://ru.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        500 http://ru.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu xenial-security/main i386 Packages
     7.0.4-7ubuntu2 500
        500 http://ru.archive.ubuntu.com/ubuntu xenial/main amd64 Packages
        500 http://ru.archive.ubuntu.com/ubuntu xenial/main i386 Packages

-------------------

# kill -l
 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP
 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1
11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM
16) SIGSTKFLT 17) SIGCHLD 18) SIGCONT 19) SIGSTOP 20) SIGTSTP
21) SIGTTIN 22) SIGTTOU 23) SIGURG 24) SIGXCPU 25) SIGXFSZ
26) SIGVTALRM 27) SIGPROF 28) SIGWINCH 29) SIGIO 30) SIGPWR
31) SIGSYS 34) SIGRTMIN 35) SIGRTMIN+1 36) SIGRTMIN+2 37) SIGRTMIN+3
38) SIGRTMIN+4 39) SIGRTMIN+5 40) SIGRTMIN+6 41) SIGRTMIN+7 42) SIGRTMIN+8
43) SIGRTMIN+9 44) SIGRTMIN+10 45) SIGRTMIN+11 46) SIGRTMIN+12 47) SIGRTMIN+13
48) SIGRTMIN+14 49) SIGRTMIN+15 50) SIGRTMAX-14 51) SIGRTMAX-13 52) SIGRTMAX-12
53) SIGRTMAX-11 54) SIGRTMAX-10 55) SIGRTMAX-9 56) SIGRTMAX-8 57) SIGRTMAX-7
58) SIGRTMAX-6 59) SIGRTMAX-5 60) SIGRTMAX-4 61) SIGRTMAX-3 62) SIGRTMAX-2
63) SIGRTMAX-1 64) SIGRTMAX

-------------------

# php -v
PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies

-------------------

# php -i | grep pcntl
pcntl
pcntl support => enabled

-------------------

get_defined_constants () function shows the following signals are defined in PHP:

SIGHUP: 1
SIGQUIT: 3
SIGTRAP: 5
SIGABRT: 6
SIGBUS: 7
SIGFPE: 8
SIGKILL: 9
SIGUSR1: 10
SIGUSR2: 12
SIGPIPE: 13
SIGALRM: 14
SIGTERM: 15
SIGCLD: 17
SIGCHLD: 17
SIGCONT: 18
SIGTSTP: 20
SIGTTIN: 21
SIGTTOU: 22
SIGURG: 23
SIGXCPU: 24
SIGXFSZ: 25
SIGVTALRM: 26
SIGPROF: 27
SIGWINCH: 28
SIGPOLL: 29
SIGPWR: 30
SIGBABY: 31

-------------------

This code works on Ubuntu 14.04 with PHP 5.6, but not work on Ubuntu 16.04 with PHP 7.0.8:

<?PHP
declare(ticks = 1);

function sig_handler($signal)
{
 exit("received signal: ".$signal);
}

echo getmypid().PHP_EOL;

if (!pcntl_signal(SIGTERM, "sig_handler")) exit('handler is not registered');

while (true) {
 //some code
}
?>

Function sig_handler() is not called if launch this script in CLI and try to send a signal through the "kill" ("kill PID", "kill -15 PID", "kill -SIGTERM PID"). I tried to register a handler to other signals (SIGUSR1, SIGPWR, etc.) and send them, but the behavior has not changed.

Tags: pcntl php7.0.8
Evgeniy (eamaksimov)
description: updated
Revision history for this message
Nish Aravamudan (nacc) wrote :

Hello and thank you for filing this bug report!

Is this something you are able to test with upstream PHP7.0? Or perhaps if there is an upstream bug report? I will spend some time tomorrow looking through the upstream changes to see if anything sticks out to me.

Changed in php7.0 (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
importance: Medium → Low
assignee: nobody → Nish Aravamudan (nacc)
Revision history for this message
Nish Aravamudan (nacc) wrote :

7.0.15 is now in 16.04+ via -updates; can you verify if this is still reproducible?

Changed in php7.0 (Ubuntu):
status: Triaged → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.