Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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. 
share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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