#44614 [Opn->Fbk]: signal handlers fail to execute when signal interrupts a socket_select

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               44614
 Updated by:       [email protected]
 Reported By:      dan at auctionharmony dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         PCNTL related
 Operating System: Linux
 PHP Version:      5.2.6RC3
 New Comment:

I can't reproduce with the following code:

<?php
declare(ticks=1);

function sig_handler($signo) {
        echo __FUNCTION__ . " called\n";
}
pcntl_signal(SIGINT, "sig_handler");

$socket = socket_create_listen(1234);
$read = array($socket);
$n = NULL;
$foo = socket_select($read, $n, $n, NULL);
?>

The signal handler is called just after socket_select returns.



Previous Comments:
------------------------------------------------------------------------

[2008-04-02 15:24:44] dan at auctionharmony dot com

Description:
------------
When waiting in a socket_select (and presumably a stream_select, but I
have not tested it) a previously set signal handler is not executed when
a signal is received.  The select returns false as would be expected.

The analog code in C is also attached.  It correctly executes the
signal handler.

Tested on PHP 5.1.6(CentOS), 5.2.6_rc1(Gentoo), 5.2.6-rc3(Gentoo)

Reproduce code:
---------------
//PHP: when SIGINT is recieved, socket_select returns false,
sig_handler is not run
pcntl_signal(SIGINT, "sig_handler");
$sock = socket_create_listen($port);
$read_socks = array($sock);
$n = NULL;
$foo = socket_select($read_socks, $n, $n, NULL);

//C: when SIGINT is recieved, select returns -1, sig_handler is run
signal(SIGINT, sig_handler);
int sockfd = socket(PF_INET, SOCK_STREAM, 0); // do some error
bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr);
listen(sockfd, 10);

fd_set read_fds;
FD_ZERO(&read_fds);
FD_SET(sockfd, &read_fds);

select(sockfd+1, &read_fds, NULL, NULL, NULL)


Expected result:
----------------
I expect the result to be like the equivalent C where the signal
handler is run and select returns error.

Actual result:
--------------
Select returns false, but unlike the equivalent C the signal handler is
not run


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


-- 
Edit this bug report at http://bugs.php.net/?id=44614&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.