+2015-09-21 Pádraig Brady <P@draigBrady.com>
+
+ nanosleep: fix return code for interrupted replacement
+ * lib/nanosleep.c (nanosleep): In the replaced nanosleep, ensure
+ that we return -1 in the case the call is interrupted by a signal,
+ rather than the current value of 1.
+ Diagnosed and tested by Daniel Richard G.
+
2015-09-19 Paul Eggert <eggert@cs.ucla.edu>
Diagnose ERE '()|\1'
/* Suspend execution for at least *TS_DELAY seconds. */
-static void
+static int
my_usleep (const struct timespec *ts_delay)
{
struct timeval tv_delay;
tv_delay.tv_usec = 0;
}
}
- select (0, NULL, NULL, NULL, &tv_delay);
+ return select (0, NULL, NULL, NULL, &tv_delay);
}
/* Suspend execution for at least *REQUESTED_DELAY seconds. The
suspended = 0;
- my_usleep (requested_delay);
-
- if (suspended)
+ if (my_usleep (requested_delay) == -1)
{
- /* Calculate time remaining. */
- /* FIXME: the code in sleep doesn't use this, so there's no
- rush to implement it. */
+ if (suspended)
+ {
+ /* Calculate time remaining. */
+ /* FIXME: the code in sleep doesn't use this, so there's no
+ rush to implement it. */
- errno = EINTR;
+ errno = EINTR;
+ }
+ return -1;
}
/* FIXME: Restore sig handler? */
- return suspended;
+ return 0;
}
#endif