-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DTrace v2 doesn't automatically copy tracing sessions across fork boundaries the way v1 used to (in the kernel). Instead. re-register DOF in the forked child just like it was registered for the original process at ELF constructor invocation time. We do this using pthread_atfork, but older glibc puts pthread_atfork in -lpthread which clients are obviously not required to link with; so we spot such old glibcs and directly call the corresponding not-exactly-internal glibc function if found. This function is always in libc; a call to it is found in libc_nonshared and it is directly used by systemd, so it's ABI-stable and safe to call.) In the process, clean up some messes: moving the device file I/O into a separate function means we no longer need to close it on error in a dozen places; don't mess around with temporary variables just to open /proc/self/maps, which is a literal string (back in the day it used to be /proc/%i/maps where %i was getpid(), but not for years). (Technically, calling ioctl() from a pthread_atfork() handler is dodgy as it is not async-signal-safe. In practice, in this implementation, it's fine. The use of dprintf() in error messages is more likely to be problematic.) Signed-off-by: Nick Alcock <nick.alcock@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
1 parent
1cb8037
commit 6b59a97
Showing
3 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters