diff options
author | Lennart Poettering <lennart@poettering.net> | 2012-03-07 19:54:31 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2012-03-07 19:54:31 +0100 |
commit | c5b2222fbbc697b641b093694afa71f31b8ba6e9 (patch) | |
tree | 5f5766287885823c9e9528a3db0d46fb9fe27c5b | |
parent | ca28e201c6ae5c06272b61861072f66bca172ed0 (diff) |
core: add 8 threads to coredump, to make things more interesting
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | segfault.c | 20 |
2 files changed, 21 insertions, 1 deletions
@@ -1,4 +1,4 @@ -CFLAGS=-Wextra -Wall -O0 -g -D_GNU_SOURCE +CFLAGS=-Wextra -Wall -O0 -g -D_GNU_SOURCE -pthread all: segfault generate core @@ -6,11 +6,31 @@ #include <unistd.h> #include <stdlib.h> #include <limits.h> +#include <pthread.h> +#include <string.h> + +static void *hang(void *arg) { + pause(); + return NULL; +} int main(int argc, char *argv[]) { int *p = 0; struct rlimit rl; char path[PATH_MAX]; + unsigned i; + + /* Create 8 threads to make things more interesting */ + for (i = 0; i < 8; i++) { + pthread_t t; + int r; + + r = pthread_create(&t, NULL, hang, NULL); + if (r != 0) { + fprintf(stderr, "failed to create thread: %s", strerror(r)); + return EXIT_FAILURE; + } + } if (getrlimit(RLIMIT_CORE, &rl) < 0) { fprintf(stderr, "getrlimit() failed: %m"); |