Attaching strace to a process that is using a lot of cpu, shows that the pid is 'killed' over and over.

The process is using 130% cpu. What is a tgkill( SIG_0) ?

strace -p 3876 

nanosleep({0, 100000}, NULL) = 0 
tgkill(3876, 3884, SIG_0) = 0 
tgkill(3876, 3885, SIG_0) = 0 ...repeats over and over. 

From man tgkill:

tgkill() sends the signal sig to the thread with the thread ID tid in the thread group tgid. (By contrast, kill(2) can only be used to send a signal to a process (i.e., thread group) as a whole, and the signal will be delivered to an arbitrary thread within that process.)

Which just leaves us the question of what signal 0 represents. The answer is, none at all:

If you have a process ID but aren't sure whether it's valid, you can use the most unlikely of candidates to test it: the kill command. If you don't see any reference to this on the kill(1) man page, check the info pages. The man/info page states that signal 0 is special and that the exit code from kill tells whether a signal could be sent to the specified process (or processes).

The tgkill calls, then, are testing for the existence of various threads within whatever process you're monitoring via strace. The return value of 0 indicates that the threads so tested do exist; the question to answer now is, why is the process looping over the test? (I assume that's what it's doing, at any rate; presumably if it ever did anything else that you saw, you'd have mentioned it in your question.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.