Что такое SIG_0 при взгляде на полосу

1541
spuder

Присоединение strace к процессу, использующему большое количество процессоров, показывает, что pid «убивается» снова и снова.

Процесс использует 130% процессорного времени. Что такое tgkill (SIG_0)?

strace -p 3876   nanosleep(, NULL) = 0  tgkill(3876, 3884, SIG_0) = 0  tgkill(3876, 3885, SIG_0) = 0 ...repeats over and over.  
1

1 ответ на вопрос

3
Aaron Miller

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

Похожие вопросы