These are the individual threads of Packet Receiver process. Is there any way to kill any individual thread? Does Linux provide any specific command which can kill or send stop signal to any particular thread under a process?
It generally is pretty dangerous to kill an individual thread from a larger process. That thread might:
- Be modifying some shared state with other threads that could become corrupted
- Be holding some lock which never gets freed, causing the lock to become indefinitely unavailable
- ...or any number of other things which might cause other threads to go wrong.
In general, outside of management and synchronisation by the application itself, killing individual threads is not something that makes sense to do.
(I don't exactly know what effect would have
tkill - e.g. with
SIGTERM - on a thread)
The pthreads(7) library uses low-level stuff (including some signal(7)-s and futex(7)-s etc...; see also nptl(7)) and if you raw-killed (with
tgkill) some individual thread, your process would be in some wrong state (so undefined behavior) because some internal invariant would be broken.
So study the documentation of your packet receiver program and find some other way. If it is free software, study its source code and improve it.
And in practice, signals and threads don't marry well. Read some pthread tutorial.
A common trick, when coding a multi-threaded program (and wanting to handle external signals like
SIGTERM) is to use a pipe(7) to your own process and poll(2) that pipe in some other thread (you might also consider the Linux specific signalfd(2)), with a signal hander write(2)-ing a byte or a few of them into that pipe. That well known trick is well explained in Qt documentation (and you could use it in your own program, even without Qt).