I want to use setitimer()
(or less probable, the alarm()
) in multithreaded process in linux 2.6+ with NPTL-enabled libc. Which thread will receive sigalarm (SIGALRM)
from kernel?
Thanks.
2014-04 update: How should I set the setitimer()
in multithreaded program, if I want to write a profiling utility like gperftools's cpuprofile; but in my tool I want to support both dynamically linked programs (so it is possible to inject my own library to init profiling) and statically linked programs (without the possibility of doing ^^^^^^).
My current profiling tool works with setting setitimer
just after fork()
and before exec()
, and it also uses ptrace
to get control over the target program and to hijack SIGPROF/SIGVPROF/SIGALRM generated by the setitimer
. I have no exact idea how it works with multithreaded programs.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…