Browse Source

fix clock_nanosleep error case

posix requires that EINVAL be returned if the first parameter specifies
the cpu-time clock of the calling thread (CLOCK_THREAD_CPUTIME_ID).
linux returns ENOTSUP instead so we handle this.
Daniel Sabogal 8 years ago
parent
commit
3ca2d2d4ae
1 changed files with 3 additions and 1 deletions
  1. 3 1
      src/time/clock_nanosleep.c

+ 3 - 1
src/time/clock_nanosleep.c

@@ -1,8 +1,10 @@
 #include <time.h>
+#include <errno.h>
 #include "syscall.h"
 #include "libc.h"
 
 int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem)
 {
-	return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
+	int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem);
+	return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r;
 }