summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-03-07 19:54:31 +0100
committerLennart Poettering <lennart@poettering.net>2012-03-07 19:54:31 +0100
commitc5b2222fbbc697b641b093694afa71f31b8ba6e9 (patch)
tree5f5766287885823c9e9528a3db0d46fb9fe27c5b
parentca28e201c6ae5c06272b61861072f66bca172ed0 (diff)
core: add 8 threads to coredump, to make things more interesting
-rw-r--r--Makefile2
-rw-r--r--segfault.c20
2 files changed, 21 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 6fe65ea..62df572 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/segfault.c b/segfault.c
index e0e759c..025cfa6 100644
--- a/segfault.c
+++ b/segfault.c
@@ -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");