Browse Source

fix ESRCH error handling for clock_getcpuclockid

the syscall used to probe availability of the clock fails with EINVAL
when the requested pid does not exist, but clock_getcpuclockid is
specified to use ESRCH for this purpose.
Eugene Yudin 2 years ago
parent
commit
baaf257f05
1 changed files with 1 additions and 0 deletions
  1. 1 0
      src/time/clock_getcpuclockid.c

+ 1 - 0
src/time/clock_getcpuclockid.c

@@ -8,6 +8,7 @@ int clock_getcpuclockid(pid_t pid, clockid_t *clk)
 	struct timespec ts;
 	clockid_t id = (-pid-1)*8U + 2;
 	int ret = __syscall(SYS_clock_getres, id, &ts);
+	if (ret == -EINVAL) ret = -ESRCH;
 	if (ret) return -ret;
 	*clk = id;
 	return 0;