I have a Python script that spawns a few subprocesses but never more than
n at a time.
I want to write a shell script to confirm that it has no more than
n subprocesses at any given time, but also that generally it has
n processes running.
If I have the PID of the Python program inside a shell script, how do I check the number of subprocesses that that PID currently has? E.g.
python script.py & pid=$! while true do # do something that prints number of subprocesses of # the process $pid to stdout sleep 1 done