about summary refs log tree commit diff
path: root/linuxthreads/bug-sleep.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
committerUlrich Drepper <drepper@redhat.com>2004-12-22 20:10:10 +0000
commita334319f6530564d22e775935d9c91663623a1b4 (patch)
treeb5877475619e4c938e98757d518bb1e9cbead751 /linuxthreads/bug-sleep.c
parent0ecb606cb6cf65de1d9fc8a919bceb4be476c602 (diff)
downloadglibc-a334319f6530564d22e775935d9c91663623a1b4.tar.gz
glibc-a334319f6530564d22e775935d9c91663623a1b4.tar.xz
glibc-a334319f6530564d22e775935d9c91663623a1b4.zip
(CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4.
Diffstat (limited to 'linuxthreads/bug-sleep.c')
-rw-r--r--linuxthreads/bug-sleep.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/linuxthreads/bug-sleep.c b/linuxthreads/bug-sleep.c
new file mode 100644
index 0000000000..f29a6b73c0
--- /dev/null
+++ b/linuxthreads/bug-sleep.c
@@ -0,0 +1,34 @@
+/* PR libc/4005 */
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <time.h>
+
+void *
+run_thread (void *a)
+{
+  while (1)
+    {
+      sleep (10);
+    }
+  return 0;
+}
+
+int
+main (void)
+{
+  pthread_t thr;
+  void *result;
+  alarm (4);
+  printf ("Starting thread.\n");
+  pthread_create (&thr, 0, run_thread, 0);
+  sleep (2);
+  printf ("Canceling thread.\n");
+  pthread_cancel (thr);
+  pthread_join (thr, &result);
+  if (result == PTHREAD_CANCELED)
+    printf ("Thread canceled.\n");
+  else
+    printf ("Thread exited.\n");
+  return 0;
+}