So I came across a piece of code that looked like this:
if (fork() != 0)
exit(0);
setsid();
if (fork() != 0)
exit(0);
What each individual system call can easily be looked up and understood (well, maybe not setsid), but what the entire block of code is doing is not clear at all
…and I really can’t say I understand the mechanics of it all to explain myself. But this python code segment’s comments does a good job of what the entire block of code is trying to do—daemonize a process completely.