chiark / gitweb /
correct lock format to match that of minicom
authorwry@lapis <none@none>
Wed, 21 Jul 2010 10:57:13 +0000 (11:57 +0100)
committerwry@lapis <none@none>
Wed, 21 Jul 2010 10:57:13 +0000 (11:57 +0100)
SerialLock.pm

index 4ea480e..a6b0a29 100644 (file)
@@ -45,7 +45,7 @@ sub slock($) {
        my $lck = "/var/lock/LCK..".$dev;
 
        return 0 if -f $lck;
-       # TODO determine whether lock is stale
+       # TODO determine whether lock is stale and try to override it
 
        unless (open(LF, "+>$lck")) {
                carp "cannot open $lck";
@@ -54,7 +54,10 @@ sub slock($) {
        my $rv=0;
 
        if (flock(LF, LOCK_EX)) {
-               print LF "$$ $0 $<\n";
+               my $me = $0;
+               $me =~ s,.*/,,;
+               my $u = (getpwuid($<))[0];
+               printf LF "%05u %s %s\n",($$,$me,$u);
                $rv=1;
        } else {
                carp "cannot flock $lck";