mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
Make pid & uid available while handling realtime signals
This commit is contained in:
parent
a109fddba4
commit
b5cb3ac8ec
@ -1276,6 +1276,12 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#if defined(SIGRTMIN) && defined(SIGRTMAX)
|
||||
if (SIGRTMIN <= signo && signo <= SIGRTMAX) {
|
||||
add_assoc_long_ex(user_siginfo, "pid", sizeof("pid")-1, siginfo->si_pid);
|
||||
add_assoc_long_ex(user_siginfo, "uid", sizeof("uid")-1, siginfo->si_uid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
20
ext/pcntl/tests/pcntl_realtime_signal.phpt
Normal file
20
ext/pcntl/tests/pcntl_realtime_signal.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
pcntl_signal() context of realtime signal
|
||||
--SKIPIF--
|
||||
<?php if (!defined('SIGRTMIN')) die("skip realtime signal not supported"); ?>
|
||||
<?php if (!extension_loaded("pcntl")) print "skip"; ?>
|
||||
<?php if (!extension_loaded("posix")) die("skip posix extension not available"); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
pcntl_signal(SIGRTMIN, function ($signo, $siginfo) {
|
||||
printf("got realtime signal from %s, ruid:%s\n", $siginfo['pid'] ?? '', $siginfo['uid'] ?? '');
|
||||
});
|
||||
posix_kill(posix_getpid(), SIGRTMIN);
|
||||
pcntl_signal_dispatch();
|
||||
|
||||
echo "ok\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
%rgot realtime signal from \d+, ruid:\d+%r
|
||||
ok
|
Loading…
Reference in New Issue
Block a user