我有一个简单的测试程序:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <linux/seccomp.h>
#include <sys/prctl.h>
#include <sys/syscall.h>
void *do_work(void *args) {
prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT);
printf("OK.\n");
}
int main() {
pthread_t t;
int ret;
ret = pthread_create(&t, NULL, do_work, NULL);
if (ret != 0) {
printf("Could not create thread, error is %d.\n", ret);
return 1;
}
ret = pthread_join(t, NULL);
if (ret != 0) {
printf("Could not join thread, error is %d.\n", ret);
return 2;
}
printf("Program done.\n");
return 0;
}
这在 Ubuntu 16.04 中没有打印任何内容就死锁了。通过阅读有关 seccomp 的文档,我不清楚为什么会发生这种情况。为什么会这样?SIGKILL 不会杀死整个过程吗?