I am writing code to kill a process and all children processes.
According to this post, all children processes can be killed within the same process group by using os.killpg(pro.pid, signal.SIGTERM)
During test, I launched this process manually which spawned 5 subprocesses.
UID PID PPID C STIME TTY TIME CMD
ddd 25066 19475 0 Nov03 ? 00:00:00 /bin/sh -c gtdownload -c ~/.cghub.key --max-children 4 -vv -d https://cghub.ucsc.edu/cghub/data/analysis/download/ab0e89b4-5310-11e4-88da-adc9fc308db6 2
ddd 25067 25066 0 Nov03 ? 00:00:07 /rsrch1/rists/djiao/apps/cghub/libexec/gtdownload -c /rsrch1/rists/djiao/.cghub.key --max-children 4 -vv -d https://cghub.ucsc.edu/cghub/data/analysis/d
ddd 25073 25067 0 Nov03 ? 00:00:18 /rsrch1/rists/djiao/apps/cghub/libexec/gtdownload -c /rsrch1/rists/djiao/.cghub.key --max-children 4 -vv -d https://cghub.ucsc.edu/cghub/data/analysis/d
ddd 25077 25067 0 Nov03 ? 00:00:18 /rsrch1/rists/djiao/apps/cghub/libexec/gtdownload -c /rsrch1/rists/djiao/.cghub.key --max-children 4 -vv -d https://cghub.ucsc.edu/cghub/data/analysis/d
ddd 25081 25067 0 Nov03 ? 00:00:18 /rsrch1/rists/djiao/apps/cghub/libexec/gtdownload -c /rsrch1/rists/djiao/.cghub.key --max-children 4 -vv -d https://cghub.ucsc.edu/cghub/data/analysis/d
ddd 25085 25067 0 Nov03 ? 00:00:18 /rsrch1/rists/djiao/apps/cghub/libexec/gtdownload -c /rsrch1/rists/djiao/.cghub.key --max-children 4 -vv -d https://cghub.ucsc.edu/cghub/data/analysis/d
However when I ran os.killpg(25066, signal.SIGTERM), I got the error "OSError: [Errno 3] No such process". Why can't it find the process with that ID?