lockf(F_LOCK) requests a write lock, which requires the file to be open in write...
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 1 Mar 2008 01:20:42 +0000 (01:20 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Sat, 1 Mar 2008 01:20:42 +0000 (01:20 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2696 94cd875c-1c1d-0410-91d2-eb244daf1a30

src/lockfile.c

index eabfe68..0319062 100644 (file)
@@ -110,7 +110,7 @@ int main(int argc, char *argv[])
                   
   if ((sync_fd=open(argv[idx+1], O_WRONLY))==-1)
     perror("lockfile: open(<syncpipe>)");
-  else if ((fd=open(argv[idx], O_CREAT|O_RDONLY|O_NOFOLLOW|O_NONBLOCK, 0644))==-1)
+  else if ((fd=open(argv[idx], O_CREAT|O_WRONLY|O_NOFOLLOW|O_NONBLOCK, 0644))==-1)
     perror("lockfile: open(<lockfile>)");
   else if (unlink(argv[idx+1])==-1)
     perror("lockfile: unlink(<syncpipe>)");
@@ -122,7 +122,7 @@ int main(int argc, char *argv[])
   else while (time(0)<end_time && getppid()==ppid) {
     int                duration = end_time-time(0);
     alarm(MIN(10, MAX(duration,1)));
-    
+
     if (lockf(fd,F_LOCK,0)==-1) {
       if (errno==EINTR) continue;
       perror("lockfile: lockf()");