Re: Multiple Instances of program
From: SM Ryan (wyrmwif_at_tango-sierra-oscar-foxtrot-tango.fake.org)
Date: 11/10/05
- Previous message: Nils Olav Selåsdal: "Re: Multiple Instances of program"
- In reply to: Mavinkuli: "Re: Multiple Instances of program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 10 Nov 2005 18:07:32 -0000
"Mavinkuli" <boss_bhat@yahoo.co.in> wrote:
# I have SunOS brahma 5.8 box
# But when I compile this fix it says LOCK_EX and LOCK_NB are undefined.
# I have even included the file sys/file.h but still it fails to compile
There are also fcntl and perhaps lockf file locks if flock
is not implemented on your system. fcntl locks have similar
properties to flock.
#include <fcntl.h>
struct flock l = {0,0,0,F_WRLCK,SEEK_SET};
int lockfd = open(lockpath,O_RDWR|O_CREAT);
if (fcntl(lockfd,F_SETLK,&l)==0) {
acquired lock
}else if (errno==EACCES) {
another process has the lock
}else {
oops
}
-- SM Ryan http://www.rawbw.com/~wyrmwif/ Who's leading this mob?
- Previous message: Nils Olav Selåsdal: "Re: Multiple Instances of program"
- In reply to: Mavinkuli: "Re: Multiple Instances of program"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]