Why do daemons fork? -


i'm aware (all?) daemons fork when they're being started. i'm under impression run child processes less privileged users, if daemon http server.

why necessary though? couldn't process start , drop privileges without forking child process? "mandatory" forking, or there other special reason (other running multiple child worker processes)?

i'm new , appreciate can get.

i think daemons fork several reasons:

  1. one reason to detach process shell starts it. shells (bash, instance) kill children upon exit, unless special, shell-specific precautions made. forking generic way evade this.

  2. another reason to report daemon started.

    assume doesn't fork. how know daemon has been started successfully? can't read , parse daemon output, because daemon management programs should in generic way. way return code of program.

    indeed, if daemon failed start (for example, couldn't find config file), know immediately. hey, if daemon has been started successfully, may never return! daemon manager can't know whether daemon still trying start, or has been started, , working. fork solve problem, , forking program return success if fork worked well.

  3. as privileges, dropping them after execve less secure doing before execve. here's reason why fork handy.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -