aboutsummaryrefslogtreecommitdiffstats
path: root/pullimap
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2016-03-12 23:38:53 +0100
committerGuilhem Moulin <guilhem@fripost.org>2016-03-12 23:39:06 +0100
commit4e58fda1ae50b7fce11c567dc23dc814ce948e22 (patch)
tree2687d33c69c2df44f67c80e5f236628c874e9b4e /pullimap
parent83529ed336f5de59d043ae76be36b2b5dfba68a3 (diff)
pullimap: use fcntl(2) not flock(2) to lock the statefile.
Diffstat (limited to 'pullimap')
-rwxr-xr-xpullimap5
1 files changed, 2 insertions, 3 deletions
diff --git a/pullimap b/pullimap
index 3eb2b52..317e880 100755
--- a/pullimap
+++ b/pullimap
@@ -25,7 +25,7 @@ our $VERSION = '0.3';
my $NAME = 'pullimap';
use Errno 'EINTR';
-use Fcntl qw/O_CREAT O_RDWR O_DSYNC LOCK_EX SEEK_SET F_GETFD F_SETFD FD_CLOEXEC/;
+use Fcntl qw/O_CREAT O_RDWR O_DSYNC F_SETLK F_WRLCK SEEK_SET F_GETFD F_SETFD FD_CLOEXEC/;
use Getopt::Long qw/:config posix_default no_ignore_case gnu_getopt auto_version/;
use List::Util 'first';
use Socket qw/PF_INET PF_INET6 SOCK_STREAM/;
@@ -83,10 +83,9 @@ do {
}
sysopen($STATE, $statefile, O_CREAT|O_RDWR|O_DSYNC, 0600) or die "Can't open $statefile: $!";
+ fcntl($STATE, F_SETLK, pack('sslll', F_WRLCK, SEEK_SET, 0, 0, $$)) or die "Can't lock $statefile: $!";
my $flags = fcntl($STATE, F_GETFD, 0) or die "fcntl F_GETFD: $!";
fcntl($STATE, F_SETFD, $flags | FD_CLOEXEC) or die "fcntl F_SETFD: $!";
-
- flock($STATE, LOCK_EX) or die "Can't flock $statefile: $!";
};