return _chdir
def ignore_existing_pidfile():
- """Normally, die_if_already_running() will terminate the program with a
- message if a locked pidfile already exists. If this function is called,
- die_if_already_running() will merely log a warning."""
+ """Normally, daemonize() or daemonize_start() will terminate the program
+ with a message if a locked pidfile already exists. If this function is
+ called, an existing pidfile will be replaced, with a warning."""
global _overwrite_pidfile
_overwrite_pidfile = True
global _monitor
_monitor = True
-def die_if_already_running():
+def _die_if_already_running():
"""If a locked pidfile exists, issue a warning message and, unless
ignore_existing_pidfile() has been called, terminate the program."""
if _pidfile is None:
# Running in parent process.
os.close(wfd)
ovs.fatal_signal.fork()
- try:
- s = os.read(rfd, 1)
- except OSError, e:
- s = ""
+ while True:
+ try:
+ s = os.read(rfd, 1)
+ error = 0
+ except OSError, e:
+ s = ""
+ error = e.errno
+ if error != errno.EINTR:
+ break
if len(s) != 1:
retval, status = _waitpid(pid, 0)
if (retval == pid and
_monitor_daemon(daemon_pid)
# Running in daemon process
+ _die_if_already_running()
_make_pidfile()
def daemonize_complete():