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() */
13 /* Happens with two threads also */
14 #define THREAD_COUNT 256
20 /* Happens with any file, not just /dev/null */
21 fd
= open("/dev/null", O_RDONLY
);
25 fprintf(stderr
, "Failed to open /dev/null\n");
33 pthread_t threads
[THREAD_COUNT
];
35 pthread_attr_init(&attr
);
36 #if !defined(VGO_freebsd)
37 pthread_attr_setstacksize(&attr
, PTHREAD_STACK_MIN
);
39 for (i
= 0; i
< THREAD_COUNT
; ++i
) {
40 r
= pthread_create(&threads
[i
], &attr
, thread
, 0);
42 fprintf(stderr
, "Failed to create thread %d\n", i
);
46 pthread_attr_destroy(&attr
);
47 for (i
= 0; i
< THREAD_COUNT
; ++i
) {
48 r
= pthread_join(threads
[i
], 0);
50 fprintf(stderr
, "Failed to join thread %d\n", i
);
54 fprintf(stderr
, "Done.\n");