ID:               38273
 Updated by:       [EMAIL PROTECTED]
 Reported By:      axelluttgens at swing dot be
-Status:           Open
+Status:           Feedback
 Bug Type:         PCNTL related
 Operating System: Mac OS 10.4.7
 PHP Version:      4.4.2
 New Comment:

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip




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

[2006-07-31 19:40:17] axelluttgens at swing dot be

Description:
------------
It seems there is a problem with the construction of the return address
to be used after an interrupt handler.

Now, I'm not sure whether the problem is a general one, or more
precisely located in the socket_xxx() family of functions.
I used the socket_select() function for building the example, as I
needed a function whose execution is liable to be suspended until the
occurence of an interrupt.

But the "workaround" described hereafter anyway seems to reveal some
misbehavior.

Reproduce code:
---------------
Create an executable file, say "sigtest.php", with following contents:

#!/usr/local/bin/php

<?php

declare(ticks = 1);

$gotINT = FALSE;

function SaveINT()
{
        $GLOBALS['gotINT'] = TRUE;
        echo "Received SIGINT\n";
}

function HandleINT()
{
        echo "Handling SIGINT\n";
}

function PollSigs()
{
        if ($GLOBALS['gotINT'])
                HandleINT();
}

pcntl_signal(SIGINT, 'SaveINT');

$endpoint = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_bind($endpoint, '127.0.0.1', 12345);
socket_listen($endpoint, 10);
while (!socket_select($r = array($endpoint), $w = NULL, $e = NULL,
NULL))
        if (($err = socket_last_error()) === SOCKET_EINTR)
        {
                # $err = $err;
                PollSigs();
        }
        else
        {
                echo "socket_select() failed with $err\n";
                exit(1);
        }

?>

Expected result:
----------------
During execution of above file on the terminal, a break (^C) should
result in:

1. the capture of SIGINT, and thus the execution of SaveINT(),
2. the continuation of execution after socket_select(), and thus the
execution of HandleINT() consecutively to the call of PollSigs(). 

Actual result:
--------------
[1] With above code, launching the executable yields:

$ /Volumes/Data/Sources/sigtest.php 

^C
Warning: socket_select() unable to select [4]: Interrupted system call
in /Volumes/Data/Sources/sigtest.php on line 31
Received SIGINT
^C
Warning: socket_select() unable to select [4]: Interrupted system call
in /Volumes/Data/Sources/sigtest.php on line 31
Handling SIGINT
Received SIGINT

[2] Now, uncomment the
   # $err = $err;
line in the source and launch the executable again:

$ /Volumes/Data/Sources/sigtest.php 

^C
Warning: socket_select() unable to select [4]: Interrupted system call
in /Volumes/Data/Sources/sigtest.php on line 31
Received SIGINT
Handling SIGINT
^C
Warning: socket_select() unable to select [4]: Interrupted system call
in /Volumes/Data/Sources/sigtest.php on line 31
Received SIGINT
Handling SIGINT

The dummy instruction (ie, $err = $err;) thus allows to restore
exepected behavior.


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


-- 
Edit this bug report at http://bugs.php.net/?id=38273&edit=1

Reply via email to