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.
master
Eugene Yudin 4 years ago
committed by Rich Felker
parent
commit
baaf257f05
  1. 1
      src/time/clock_getcpuclockid.c

1
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;

Loading…
Cancel
Save