2 * Reproducer for bug #323905. See also
3 * http://bugs.kde.org/show_bug.cgi?id=323905.
6 #include <climits> /* PTHREAD_STACK_MIN */
7 #include <cstdio> /* fprintf() */
8 #include <fcntl.h> /* O_RDONLY */
10 #include <unistd.h> /* close() */
12 /* Happens with two threads also */
13 #define THREAD_COUNT 256
19 /* Happens with any file, not just /dev/null */
20 fd
= open("/dev/null", O_RDONLY
);
24 fprintf(stderr
, "Failed to open /dev/null\n");
32 pthread_t threads
[THREAD_COUNT
];
34 pthread_attr_init(&attr
);
35 pthread_attr_setstacksize(&attr
, PTHREAD_STACK_MIN
);
36 for (i
= 0; i
< THREAD_COUNT
; ++i
) {
37 r
= pthread_create(&threads
[i
], &attr
, thread
, 0);
39 fprintf(stderr
, "Failed to create thread %d\n", i
);
43 pthread_attr_destroy(&attr
);
44 for (i
= 0; i
< THREAD_COUNT
; ++i
) {
45 r
= pthread_join(threads
[i
], 0);
47 fprintf(stderr
, "Failed to join thread %d\n", i
);
51 fprintf(stderr
, "Done.\n");