In a process controlled by Supervisor, I fork child process
for i in xrange(MANAGER_PROCESS_NUM):
p = gipc.start_process(target=daemon_process, args=())
record.append(p)
for r in record:
r.join()
then in each child process, I create grandchild process:
w = gipc.start_process(target=self._pool_worker, daemon=True)
How can I kill all the child processes & grandchild processes when I run "supervisorctl stop xxx" to stop my main process?
You have a couple options:
Modify your Python programs so that when they receive signals like
SIGTERMthey propagate them to the children explicitly.Enable the
supervisordoptionsstopasgroupandkillasgroup. These options are documented as sending signals to the entire process group rather than just one process.