I have a pythonPython 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 pidPID of the pythonPython program inside a shell script, how do I check the number of subprocesses that that pidPID 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