When you are run a sub processes it's back his pids. Command wait
can wait wait <process or job ID>
. Command waitpid
can you help too then you have a list of running sub processes. From process to process you can send param as pid or used in subprocess subfunction for watch ps
.From the ps man page, the status field will tell you if a thread is on the run queue (use the 'L' option to see threads) .
Create true logic of your program.