Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

pcntl_sigtimedwait

Description

The pcntl_sigtimedwait of PCNTL for PHP waits for signals, with a timeout.

Syntax

pcntl_sigtimedwait(
    array $signals,
    array &$info = [],
    int $seconds = 0,
    int $nanoseconds = 0
): int|false

Parameters

signals

The array of signals to wait for.

info

Set to an array containing information about the signal.

AllDescription
signoSignal number
errnoAn error number
codeSignal code
SIGCHLDDescription
statusExit value or signal
utimeUser time consumed
stimeSystem time consumed
pidSending process ID
uidReal user ID of sending process
SIGILL, SIGFPE, SIGSEGV, SIGBUSDescription
addrMemory location which caused fault
SIGPOLLDescription
bandBand event
fdFile descriptor number

seconds

Timeout in seconds.

nanoseconds

Timeout in nanoseconds.

Return

Returns a signal number on success, or false on failure.

Examples

1 · signals

<?

$signal = SIGHUP;

$mode = SIG_BLOCK;
$signals =
[
    $signal
];

pcntl_sigprocmask($mode, $signals);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$return = pcntl_sigtimedwait($signals);

echo $return;

?>
1

2 · info · all

<?

$signal = SIGHUP;

$mode = SIG_BLOCK;
$signals =
[
    $signal
];

pcntl_sigprocmask($mode, $signals);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$return = pcntl_sigtimedwait($signals, $info);

echo $return . PHP_EOL;
print_r($info);

?>
1
Array
(
    [signo] => 1
    [errno] => 0
    [code] => 0
)

3 · info · SIGCHLD

<?

$signal = SIGCHLD;

$mode = SIG_BLOCK;
$signals =
[
    $signal
];

pcntl_sigprocmask($mode, $signals);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$return = pcntl_sigtimedwait($signals, $info);

echo $return . PHP_EOL;
print_r($info);

?>
17
Array
(
    [signo] => 17
    [errno] => 0
    [code] => 0
    [status] => 0
    [utime] => 0
    [stime] => 0
    [pid] => 32038
    [uid] => 1175
)

4 · info · SIGILL

<?

$signal = SIGILL;

$mode = SIG_BLOCK;
$signals =
[
    $signal
];

pcntl_sigprocmask($mode, $signals);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$return = pcntl_sigtimedwait($signals, $info);

echo $return . PHP_EOL;
print_r($info);

?>
4
Array
(
    [signo] => 4
    [errno] => 0
    [code] => 0
    [addr] => 5046586604867
)

5 · info · SIGPOLL

<?

$signal = SIGPOLL;

$mode = SIG_BLOCK;
$signals =
[
    $signal
];

pcntl_sigprocmask($mode, $signals);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$return = pcntl_sigtimedwait($signals, $info);

echo $return . PHP_EOL;
print_r($info);

?>
29
Array
(
    [signo] => 29
    [errno] => 0
    [code] => 0
    [band] => 5046586604838
    [fd] => 0
)

6 · seconds

<?

$signal = SIGHUP;

$mode = SIG_BLOCK;
$signals =
[
    $signal
];

pcntl_sigprocmask($mode, $signals);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$seconds = 1;

$return = pcntl_sigtimedwait($signals, $info, $seconds);

echo $return . PHP_EOL;
print_r($info);

?>
1
Array
(
    [signo] => 1
    [errno] => 0
    [code] => 0
)

7 · nanoseconds

<?

$signal = SIGHUP;

$mode = SIG_BLOCK;
$signals =
[
    $signal
];

pcntl_sigprocmask($mode, $signals);

$process_id = posix_getpid();

posix_kill($process_id, $signal);

$seconds = 1;
$nanoseconds = 1;

$return = pcntl_sigtimedwait($signals, $info, $seconds, $nanoseconds);

echo $return . PHP_EOL;
print_r($info);

?>
1
Array
(
    [signo] => 1
    [errno] => 0
    [code] => 0
)
HomeMenu