From 508dae94e95b4e412625a8782a41e1ea10e0338b Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Fri, 15 Jun 2012 16:50:35 +0300 Subject: BaseScript: write pidfile atomically to avoid corrupt pidfiles. --- python/skytools/scripting.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'python/skytools/scripting.py') diff --git a/python/skytools/scripting.py b/python/skytools/scripting.py index c7791dbc..61b4aa6a 100644 --- a/python/skytools/scripting.py +++ b/python/skytools/scripting.py @@ -72,10 +72,9 @@ def run_single_process(runnable, daemon, pidfile): try: if pidfile: - f = open(pidfile, 'w') + data = str(os.getpid()) + skytools.write_atomic(pidfile, data) own_pidfile = True - f.write(str(os.getpid())) - f.close() runnable.run() finally: -- cgit v1.2.3