Page MenuHomeFreeBSD

libsys: fix sleep(3)/usleep(3) cancel behavior

Authored by kib on Feb 23 2024, 2:57 PM.
Referenced Files
Unknown Object (File)
Tue, Jul 9, 2:55 AM
Unknown Object (File)
Thu, Jul 4, 6:21 AM
Unknown Object (File)
Thu, Jun 27, 6:18 PM
Unknown Object (File)
Jun 6 2024, 6:21 AM
Unknown Object (File)
May 17 2024, 12:13 PM
Unknown Object (File)
May 7 2024, 2:25 AM
Unknown Object (File)
May 5 2024, 5:08 PM
Unknown Object (File)
Apr 26 2024, 3:38 AM


Move functions back to libc/gen sources; they are only versioned from
libc and not libsys.
Access libsys interposing slots using __libsys_interposing_slot()
instead of direct __libsys_interposing array dereference, which cannot
work from libc.

Reported by:    glebius

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

kib requested review of this revision.Feb 23 2024, 2:57 PM
This revision is now accepted and ready to land.Feb 23 2024, 5:22 PM
This revision was automatically updated to reflect the committed changes.
jrtc27 added inline comments.

Why not just call nanosleep(2) which can access this directly?


I think this code just evolved that way. Calling nanosleep() from libc did not work, so it needed explicit interposing. Then for the same reason it needed the interposing call in libsys.
But back into libc, with nanosleep() located in libsys, it should be no longer needed.

Feel free to change, assuming it works.


I was wrong, it is more complicated. Originally, the call was to _nanosleep() and not sleep, due to libc namespacing. Right now _nanosleep() in libsys is same as __sys_nanosleep(), i.e. not interposed. So the indirection through the slot is required there.

Or we should change _nanosleep() to be alias for nanosleep() in libsys.