From:             dan at auctionharmony dot com
Operating system: Linux
PHP version:      5.2.6RC3
PHP Bug Type:     PCNTL related
Bug description:  signal handlers fail to execute when signal interrupts a 
socket_select

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 bug report at http://bugs.php.net/?id=44614&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44614&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44614&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44614&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44614&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44614&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44614&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44614&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44614&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44614&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44614&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44614&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44614&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44614&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44614&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44614&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44614&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44614&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44614&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44614&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44614&r=mysqlcfg

Reply via email to