[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: fcntl(HANDLE, F_GETLK,&fl) with perl

Bill Allombert <allomber@math.u-bordeaux.fr> writes:

> Hello Debian-devel,
> I try to code the following in perl
>   struct flock fl;
>   if (fcntl(fd,F_GETLK,&fl) == -1)
> to query the dpkg lock.
> I have tried the above 
> fcntl DPKG_LOCKFILE,F_GETLK, \%fl;
> but it does not seems to work. In fact the documentation
> is unclear whether a struct flock can be passed at all
> (some form of fcntl use a long arg instead).

You have to pack the structure by hand. This works for me:

  use Config;
  my $packspec = $Config{uselargefiles} ? "ssqql" : "sslll";
  my $lk = "";
  my ($l_type, $l_whence, $l_start, $l_len, $l_pid) = unpack($packspec, $lk);


Reply to: