VividCortex/godaemon — pull request #15 by gkristic (2014-05-02 16:41:15+00:00)
Title: Add support to keep files open

Support is added to keep certain files opened in the daemon (shouldn't be used for keeping a tty, of course). Files that are locked by an flock() call in the parent will still be locked in the daemon process, without daemonization having released the lock ever, which avoids race conditions. Also, a function was added so that the application can know the current daemonization stage in case it wants to avoid repeated code. (Recall that this is not a real fork() but a complete restart of the process, so the portion before MakeDaemon() will effectively run thrice.) Knowing the stage is particularly relevant when using files, cause they should be opened (and possibly locked) only at the parent. MakeDaemon() will create a different descriptor for them later.

Closes #8 and #14.