Skip to content

Commit fe7f699

Browse files
committed
ext/pcntl: adding SIGTRAP handling for freebsd.
if a restricted file descriptor based syscall by the system had been attempted, a SIGTRAP is raised with the syscall id. close GH-14266
1 parent ace18f4 commit fe7f699

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ PHP NEWS
146146
. Added pcntl_getcpu for Linux/FreeBSD/Solaris/Illumos. (David Carlier)
147147
. Added pcntl_getqos_class/pcntl_setqos_class for macOs. (David Carlier)
148148
. Added SIGCKPT/SIGCKPTEXIT constants for DragonFlyBSD. (David Carlier)
149+
. Added FreeBSD's SIGTRAP handling to pcntl_siginfo_to_zval. (David Carlier)
149150

150151
- PCRE:
151152
. Upgrade bundled pcre2lib to version 10.43. (nielsdos)

ext/pcntl/pcntl.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,20 @@ static void pcntl_siginfo_to_zval(int signo, siginfo_t *siginfo, zval *user_sigi
10671067
add_assoc_long_ex(user_siginfo, "fd", sizeof("fd")-1, siginfo->si_fd);
10681068
# endif
10691069
break;
1070+
#endif
1071+
1072+
#ifdef SIGTRAP
1073+
case SIGTRAP:
1074+
# if defined(si_syscall) && defined(__FreeBSD__)
1075+
if (siginfo->si_code == TRAP_CAP) {
1076+
add_assoc_long_ex(user_siginfo, "syscall", sizeof("syscall")-1, (zend_long)siginfo->si_syscall);
1077+
} else {
1078+
add_assoc_long_ex(user_siginfo, "trapno", sizeof("trapno")-1, (zend_long)siginfo->si_trapno);
1079+
}
1080+
1081+
# endif
1082+
break;
1083+
10701084
#endif
10711085
}
10721086
#if defined(SIGRTMIN) && defined(SIGRTMAX)

0 commit comments

Comments
 (0)