#define _GNU_SOURCE #include #include #include #include #include static char stack[32768]; static int tid; static int foo(void *p) { syscall(SYS_getpid); syscall(SYS_getpid); syscall(SYS_exit, 0); } int main() { int pid = getpid(); for (;;) { int x = clone(foo, stack+sizeof stack, CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND |CLONE_THREAD|CLONE_SYSVSEM //|CLONE_SETTLS |CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID |CLONE_DETACHED, 0, &tid, 0, &tid); syscall(SYS_futex, &tid, FUTEX_WAIT, x, 0); /* Should fail... */ syscall(SYS_tgkill, pid, tid, SIGKILL); } }