« Previous | Next » 

Revision 7d88772a

ID7d88772a2e6e5dc44287053b0e55dfd2b3e0b653

Added by Iustin Pop about 15 years ago

Rework the daemonization sequence

The current fork+close fds sequence has deficiencies which are hard to
work around:
- logging can start logging before we fork (e.g. if we need to emit
messages related to master checking), and thus use FDs which we
can't track nicely
- the queue locks the queue file, and again this fd needs to be kept
open which is hard from the main loop (and this error is currently
hidden by the fact that we don't log it)

Given the above, it's much simpler, in case we will fork later, to close
file descriptors right at the beginning of the program, and in Daemonize
only close/reopen the stdin/out/err fds.

In addition, we also close() the handlers we remove in SetupLogging so
that the cleanup is more thorough.

Reviewed-by: imsnah

Files

  • added
  • modified
  • copied
  • renamed
  • deleted

View differences