Bug 27417

Summary: glibc lacks define for sigev_notify_thread_id
Product: glibc Reporter: Aliaksey Kandratsenka <alkondratenko>
Component: libcAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: normal CC: drepper.fsp, fweimer
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

Description Aliaksey Kandratsenka 2021-02-14 20:40:43 UTC
On linux (and freebsd) man page for sigevent lists support for event notification kind that sends given signal to given thread.

Linux kernel headers define sigev_notify_thread_id in linux/signal.h, but this header is actually unusable in practice: https://bugzilla.kernel.org/show_bug.cgi?id=200081

Both freebsd and musl actually have this macro defined under <signal.h>, so would be reasonable for glibc to also do same.

I guess this might be relevant to "famous" issue of glibc not having gettid exposed as well. Since in order to use this kind of sigevent someone needs to use tid. But tid is straightforward to get by using syscall function.

Also notably, glibc does "support" the feature by having sigevent struct with _sigev_un._tid field, just not via "standard" naming.

Context: gperftools cpu profiler has a feature to use per-thread cpu time timers for profiling "ticks", since stock interval timers commonly have skewed tickings. E.g. see: https://github.com/golang/go/issues/14434. And using per-thread cpu timers obviously depends on this sigevent feature.