Hi,
When you normally run something in the background, and it does some output, then the output is shown on your terminal, possibly messing up your screen.
daemonizing is something you do to a process for which you don't care for such output, or a process that should still be running after you logged out or something. It is, kind of, like running a windows service.
When any process terminates, it has a return value (called "exit status"). This exit status must be read by someone, otherwise the process will not go a way (it will become a "zombie"). Reading the exit status is the responsibility of the parent process (i.e. the process that started the process that is now exiting), because it knows exactly which processes it started and what the exit status means.
However, when the parent process terminates first, then it is no longer around to read the exit status of the child process. When this happens, reading the childs exit status becomes the responsability of the "init" process. The init process never exits, and therefore can always read other processes exit statusses. Because init doesn't know what the exit status means, it ignores it. It just reads the exit status for cleanup purposes.
When daemonizing, the exact same thing happens: the actual process is started in the background, and then the parent dies. Therefore, when the daemon process terminates, its exit status is read by init. In a sense, you could say the process is "added to init".
Usually, when people talk about "adding something to init" it usually means that the process is actually started by the init process when the system boots. This is something entirely different (which caused some confusion with the previous poster), although most such processes are daemonized, and therefore their exit status will be read by init as well.
Groetjes,
Kees-Jan
|