Here is the official explanation of daemon
flag in python multiprocessing:
When a process exits, it attempts to terminate all of its daemonic child processes.
By my understanding, the parent process will kill its children whose daemon flag is set to be True when it exits.
Below is the code I used to prove my guess. But the result is different.
import multiprocessing
def child():
while True:
pass
for x in xrange(1, 4):
proc = multiprocessing.Process(target=child, args=())
proc.daemon=True
proc.start()
while True:
pass
The above starts 4 child processes and one main process. I killed the main process but the 4 children did not exit.
So why are they not terminated by main since the daemon is set to be true?