wolfcw / libfaketime

libfaketime modifies the system time for a single application
https://github.com/wolfcw/libfaketime
GNU General Public License v2.0
2.64k stars 321 forks source link

select shim does not rescale the values returned in timespec #382

Open RobertHenry6bev opened 2 years ago

RobertHenry6bev commented 2 years ago

The man(2) page for select says: On Linux, select() modifies timeout to reflect the amount of time not slept; most other implementations do not do this. (POSIX.1 permits either behavior.)

The shim for select does not modify its timespec argument on return. The real call to select is given a pointer to a local holding scaled time values, but that local is ignored when select() shim returns. I think the "time not slept" held in the local should be inversely scaled and used to modify the argument to the shim.

The pselect shim takes a const timespec argument, but then the path through glibc and the true syscall into the kernel becomes convoluted. pselect6 syscall will modify its timespec argument (if I read the man page correctly) but glibc wrapper ignores those mods, and so pselect doesn't return any indication of how much time is left.

RobertHenry6bev commented 1 year ago

has this fix been tested (and released)?