tst-eintr3.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright (C) 2003 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <errno.h>
  16. #include <pthread.h>
  17. #include <signal.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include "eintr.c"
  22. static void *
  23. tf (void *arg)
  24. {
  25. pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
  26. pthread_mutex_lock (&m);
  27. /* This call must not return. */
  28. pthread_mutex_lock (&m);
  29. puts ("tf: mutex_lock returned");
  30. exit (1);
  31. }
  32. static int
  33. do_test (void)
  34. {
  35. pthread_t self = pthread_self ();
  36. setup_eintr (SIGUSR1, &self);
  37. pthread_t th;
  38. char buf[100];
  39. int e = pthread_create (&th, NULL, tf, NULL);
  40. if (e != 0)
  41. {
  42. printf ("main: pthread_create failed: %s\n",
  43. strerror_r (e, buf, sizeof (buf)));
  44. exit (1);
  45. }
  46. /* This call must never return. */
  47. e = pthread_join (th, NULL);
  48. if (e == EINTR)
  49. puts ("pthread_join returned with EINTR");
  50. return 0;
  51. }
  52. #define EXPECTED_SIGNAL SIGALRM
  53. #define TIMEOUT 1
  54. #define TEST_FUNCTION do_test ()
  55. #include "../test-skeleton.c"