diff options
author | Marko Kreen | 2012-06-15 13:50:35 +0000 |
---|---|---|
committer | Marko Kreen | 2012-06-15 13:50:35 +0000 |
commit | 508dae94e95b4e412625a8782a41e1ea10e0338b (patch) | |
tree | b645c4ec1a7b1077983d572b8e0842aaa3c791d0 /python/skytools/scripting.py | |
parent | d4886026435ddbc94ac94326fb7d0fcf4f35155f (diff) |
BaseScript: write pidfile atomically to avoid corrupt pidfiles.
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r-- | python/skytools/scripting.py | 5 |
1 files changed, 2 insertions, 3 deletions
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: |