From 8239df4493d81db1d245eaa51fdfe5458e2d1e4f Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 13 Nov 2012 14:02:14 -0500 Subject: add sleep, allow errno '3' (ESRCH) on the open of /proc/pid/cmdline The sleep is added here simply to not completely spin cpu on waiting for the parent pid to die. the allowing of errno 3 is because I was getting this. I dont have a perfect explanation, but I suspect that the 'open' was actually getting this back from the /proc filesystem after the pid had died. Possibly in the window between when the 'open' was done and the 'read()' was done. --- cloudinit/config/cc_power_state_change.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/config/cc_power_state_change.py b/cloudinit/config/cc_power_state_change.py index 22f1aade..02434322 100644 --- a/cloudinit/config/cc_power_state_change.py +++ b/cloudinit/config/cc_power_state_change.py @@ -121,6 +121,8 @@ def run_after_pid_gone(pid, pidcmdline, timeout, log, func, args): log.warn(msg) doexit(EXIT_FAIL) + known_errnos = (errno.ENOENT, errno.ESRCH) + while True: if time.time() > end_time: msg = "timeout reached before %s ended" % pid @@ -135,8 +137,8 @@ def run_after_pid_gone(pid, pidcmdline, timeout, log, func, args): break except IOError as ioerr: - if ioerr.errno == errno.ENOENT: - msg = "pidfile '%s' gone" % cmdline_f + if ioerr.errno in known_errnos: + msg = "pidfile '%s' gone [%d]" % (cmdline_f, ioerr.errno) else: fatal("IOError during wait: %s" % ioerr) break @@ -144,6 +146,8 @@ def run_after_pid_gone(pid, pidcmdline, timeout, log, func, args): except Exception as e: fatal("Unexpected Exception: %s" % e) + time.sleep(.25) + if not msg: fatal("Unexpected error in run_after_pid_gone") -- cgit v1.2.3