At least on
$ uname -r -v -m
25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:55 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T8103 arm64
running the Posix program test.c
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
int main() {
pid_t ch = fork();
if (ch == -1) {
perror("fork");
return EXIT_FAILURE;
}
if (ch == 0) {
return EXIT_SUCCESS;
}
if (setpgid(ch, ch) == -1) {
perror("setpgid");
return EXIT_FAILURE;
}
siginfo_t stat;
if (waitid(P_PID, ch, &stat, WEXITED | WNOWAIT) == -1) {
perror("waitid");
return EXIT_FAILURE;
}
if (kill(-ch, SIGKILL) == -1) {
perror("kill");
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
as
$ clang test.c
$ ./a.out
kill: Operation not permitted
fails with EPERM even though the lifetime of the process group has not yet ended (due to the WNOWAIT).
Topic:
App & System Services
SubTopic:
Core OS