Files
withlock/got-lock.patch
Ismail Dönmez fe9d84134b Accepting request 244786 from home:mcaj:branches:Base:System
- I wrote a patch got-lock.patch to fix the trouble with the got-lock variable.I was testing the withlock and still had there the lock file after a  program already end with exit code 0. I have look on the code together with our Python expert mvidner@suse.cz and we found the got-lock variable  isn't marked ad global variable. We have tested it and with the patch the program is working very well. I send this patch also to upstream (poeml@cmdline.net)

OBS-URL: https://build.opensuse.org/request/show/244786
OBS-URL: https://build.opensuse.org/package/show/Base:System/withlock?expand=0&rev=8
2014-08-15 11:48:58 +00:00

57 lines
1.3 KiB
Diff

Index: withlock-0.3/withlock
===================================================================
--- withlock-0.3.orig/withlock
+++ withlock-0.3/withlock
@@ -64,12 +64,21 @@ for name in 'SIGBREAK', 'SIGHUP', 'SIGTE
if num: signal.signal(num, catchterm)
-def cleanup(lockfile):
+def cleanup(lockfile, verbose):
+ global got_lock
+ if verbose:
+ sys.stderr.write('got_lock is set to: %r\n' % got_lock)
+
+ if verbose:
+ sys.stderr.write('removing lockfile: %r\n' % lockfile)
+
if got_lock:
try:
os.unlink(lockfile)
except:
pass
+ else:
+ sys.stderr.write('the lockfile was not removed !\n')
def main():
@@ -132,6 +141,7 @@ def main():
lock = open(lockfile, 'w')
+ global got_lock
while 1 + 1 == 2:
try:
@@ -174,7 +184,7 @@ def main():
% lockfile)
- atexit.register(cleanup, lockfile)
+ atexit.register(cleanup, lockfile, options.verbose)
os.umask(prev_umask)
import subprocess
@@ -184,10 +194,7 @@ def main():
if options.verbose:
sys.stderr.write('command terminated with exit code %s\n' % rc)
-
- if options.verbose:
- sys.stderr.write('removing lockfile\n')
-
+
sys.exit(rc)