When a thread in a nanosleep() wait is interrupted by a non-restartable
signal, cause the nanoslep to return with EINTR.  Then, in the user-space
nonblocking select() implementation, notice this and correspondingly return
with EINTR.  This appears to fix the MySQL hang-at-exit problem.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@391 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_libpthread.c b/coregrind/vg_libpthread.c
index 8a74a5c..e575e0a 100644
--- a/coregrind/vg_libpthread.c
+++ b/coregrind/vg_libpthread.c
@@ -1909,8 +1909,14 @@
       nanosleep_interval.tv_nsec = 50 * 1000 * 1000; /* 50 milliseconds */
       /* It's critical here that valgrind's nanosleep implementation
          is nonblocking. */
-      (void)my_do_syscall2(__NR_nanosleep, 
+      res = my_do_syscall2(__NR_nanosleep, 
                            (int)(&nanosleep_interval), (int)NULL);
+      if (res == -VKI_EINTR) {
+         /* The nanosleep was interrupted by a signal.  So we do the
+            same. */
+         * (__errno_location()) = EINTR;
+         return -1;
+      }
    }
 }