Use RunLock while daemonizing which is based on flock to prevent race conditions.
More test cases for run_lock to cover the functionality used during daemonizing.