File got-lock.patch of Package withlock
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)