[mplspm]: Why can't I get flock($fh,LOCK_EX) to work?

Dave Worden dave.worden at veritas.com
Mon Oct 22 18:01:11 CDT 2001


Mark,

Here is a snippet of code that worked on HP/UX several years back. 
See if that helps. Kinda machine specific and only _sorta_ what you asked.

Regards,
--djw

######################################################################
# From HP/UX man page: man 5 fcntl
#
# The file segment locking control structure struct flock, includes th
# following members:
#  short l_type;      /* F_RDLCK, F_WRLCK or F_UNLCK */
#  short l_whence;    /* Flag - see lseek(2) */
#  off_t l_start;     /* Relative offset in bytes */
#  off_t l_len;       /* Size; if 0 then until EOF */
#  pid_t l_pid;       /* By F_GETLK - process holding lock */
#
######################################################################
sub Acquire_Daemon_Lock
{
  if (open(DAEMON_LOCK_FILE, "+>$Daemon_Lock_File"))
  {
    my($flock_struct) = pack("s s l l i", &F_WRLCK, 0, 0, 0, $$);

    if(fcntl(DAEMON_LOCK_FILE, &F_SETLK, $flock_struct))
    {
      return(1);
    }
    close(DAEMON_LOCK_FILE);
  }
  return(0);
}
######################################################################

-----Original Message-----
From: Mark Conty [mailto:Mark_Conty at cargill.com]
Sent: Monday, October 22, 2001 5:18 PM
To: mpls at pm.org
Subject: [mplspm]: Why can't I get flock($fh,LOCK_EX) to work?


I'm looking at the example in the flock() perlfunc man page, and I'm doing
it
the same as they are, but it keeps telling me that I'm specifying a bad file
number.

Anyone ever run into problems with exclusive flock() on HP-UX 10.20 or 11.x?

Thanks...
-- 
Mark Conty
APS/NAGO IT Group
Server Team - MS 64
952-984-0503


--------------------------------------------------
Minneapolis Perl Mongers mailing list

To unsubscribe, send mail to majordomo at pm.org
with "unsubscribe mpls" in the body of the message.


--------------------------------------------------
Minneapolis Perl Mongers mailing list

To unsubscribe, send mail to majordomo at pm.org
with "unsubscribe mpls" in the body of the message.



More information about the Mpls-pm mailing list