controlchan buglet

Marco d'Itri md at Linux.IT
Wed Nov 20 20:06:37 UTC 2002


If open() fails (maybe because the permissions are wrong) a perl error
is printed to stderr:

readline() on closed filehandle LOCKFILE at ./controlchan line 421.

--- controlchan.orig	2002-11-20 20:57:46.000000000 +0100
+++ controlchan	2002-11-20 21:03:30.000000000 +0100
         sleep 2;
     }
 
-    open(LOCKFILE, $lockfile);
-    my $lockpid = <LOCKFILE> || "($!)";
-    close LOCKFILE;
-    logdie("Cannot get lock $lockfile, held by $lockpid");
+    my $lockreason;
+    if (open(LOCKFILE, $lockfile)) {
+        $lockreason = 'held by ' . (<LOCKFILE> || '?');
+        close LOCKFILE;
+    } else {
+        $lockreason = $!;
+    }
+    logdie("Cannot get lock $lockfile: $lockreason");
     return undef;
 }
 


-- 
ciao,
Marco


More information about the inn-workers mailing list