locking.c: Reset alarm state before invoking the target command.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 31 May 2010 17:01:56 +0000 (18:01 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 31 May 2010 17:01:56 +0000 (18:01 +0100)
There's nothing worse than grabbing a lock, trying to do something, and
then being killed by an alarm clock midway through.

Well, there are probably are worse things, but this commit message
isn't the right place to list them.

locking.c

index f486ea4..8931dbd 100644 (file)
--- a/locking.c
+++ b/locking.c
@@ -224,7 +224,9 @@ doneopts:
       errno = 0;
   }
   signal(SIGALRM, oalrm);
-  if (ot) {
+  if (!ot)
+    alarm(0);
+  else {
     nt = time(0) - nt;
     if (nt > ot)
       raise(SIGALRM);