|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-04-02 15:24 UTC] 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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 08:00:02 2025 UTC |
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.