#define _GNU_SOURCE #include #include #include #include #include #define STACK_SIZE 4096 char stack[STACK_SIZE]; int foobar(void *arg) { printf("thread %lu\n", (unsigned long)arg); fflush(stdout); while (1) pause(); return 0; } int main() { unsigned long i; clone(foobar, stack, CLONE_THREAD | CLONE_VM | CLONE_SIGHAND, (void *)i); syscall(__NR_exit, 0); }