in reply to Keeping File Locks after Daemonization

"auto-backgrounding" uses fork (I assume). flock says:

On systems that support a real flock(), locks are inherited across fork() calls, whereas those that must resort to the more capricious fcntl() function lose the locks, making it harder to write servers.
so I'd be sure to not grab the lock until after forking.

                - tye
  • Comment on Re: Keeping File Locks after Daemonization (fork)