php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #21331 SIGINT handler not called during socket_accept() (revive of Bug #20745)
Submitted: 2003-01-02 03:07 UTC Modified: 2004-02-26 17:30 UTC
From: piotr at t-p-l dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.0 OS: Linux
Private report: No CVE-ID: None
 [2003-01-02 03:07 UTC] piotr at t-p-l dot com
this is meant as a revive of Bug #20745 .. but since its not my bug I couldnt reopen it myself .. dont know if you guys get messages from abandoned bugs .. so I opened this one)

(this was tested in the CGI executable from 4.2.3 and with the CLI executable from 4.3.0)
steps to reproduce:
install a signal handler for SIGINT (using pcntl_signal())
create a socket
bind the socket
start listening on the socket
call socket_accept() on the socket

now hit ctrl-c .. and the handler isnt called .. if the signal handler was installed with the third parameter set to false .. the call gets interrupted but the call just fails and the handler is still not called.

if you need any additional information please let me know.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-02 11:46 UTC] wez@php.net
add the following to the start of your script:

declare(ticks=2);

Signal handlers require ticks to be activated in order to be triggered.

Changing to a documentation problem.
 [2003-01-02 15:10 UTC] piotr at t-p-l dot com
ok .. so now the handler executes with that third param set to false, but it looks like code after the call to socket_accept() still a line or two of it is run before the handler kicks in.

also what is the significance of the value of the ticks define?
 [2003-01-02 15:13 UTC] piotr at t-p-l dot com
on a side but related issue .. the warning about the interrupted system call is spewed out twice .. so I guess thats a bug in itself
 [2003-01-02 15:37 UTC] piotr at t-p-l dot com
using define(ticks=1); it seems to have gotten rid of the problem with it executing extra code here is a sample

$foo = socket_accept($sock);
echo "Line One...\n";
echo "Line Two...\n";

with define(ticks=2); "Line One..." shows up before the signal handler is called .. with ticks=1 it doesnt .. so again knowing what exactly this ticks define does would help.
 [2003-01-10 02:12 UTC] polone at townnews dot com
The "ticks" aspect isn't really a change from the previous behaviour, when set as:

declare(ticks=1);

Though I would like to point out that anything using register_tick_function() will now magically get executed ALL THE TIME, even though this has to be enabled for signal handling support.
 [2003-01-10 02:17 UTC] piotr at t-p-l dot com
alright I supose its ok to close this bug then .. since the ticks thing did make it work in the end .. and the ticks problems are prety much me not understanding what really ticks do
 [2004-02-26 17:30 UTC] irchtml@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Added a note on the pcntl_signal page that declare must be used in order for signal handling to function properly (as of PHP 4.3.0).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Nov 15 15:00:01 2025 UTC