From: hsldymq Date: Wed, 27 Jun 2018 18:25:11 +0000 (+0800) Subject: Make pid & uid available while handling realtime signals X-Git-Tag: php-7.2.16RC1~6^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5cb3ac8ecab71bfe1eb7d5b2d7a48970e11a5b4;p=php Make pid & uid available while handling realtime signals --- diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 228111d351..36d2a672ab 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -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 } } /* }}} */ diff --git a/ext/pcntl/tests/pcntl_realtime_signal.phpt b/ext/pcntl/tests/pcntl_realtime_signal.phpt new file mode 100644 index 0000000000..212f15e03b --- /dev/null +++ b/ext/pcntl/tests/pcntl_realtime_signal.phpt @@ -0,0 +1,20 @@ +--TEST-- +pcntl_signal() context of realtime signal +--SKIPIF-- + + + +--FILE-- + +--EXPECTF-- +%rgot realtime signal from \d+, ruid:\d+%r +ok