summaryrefslogtreecommitdiff
path: root/python/skytools/scripting.py
diff options
context:
space:
mode:
authorMarko Kreen2012-06-15 13:50:35 +0000
committerMarko Kreen2012-06-15 13:50:35 +0000
commit508dae94e95b4e412625a8782a41e1ea10e0338b (patch)
treeb645c4ec1a7b1077983d572b8e0842aaa3c791d0 /python/skytools/scripting.py
parentd4886026435ddbc94ac94326fb7d0fcf4f35155f (diff)
BaseScript: write pidfile atomically to avoid corrupt pidfiles.
Diffstat (limited to 'python/skytools/scripting.py')
-rw-r--r--python/skytools/scripting.py5
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: