Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Flock and Aix 5.3?

Status
Not open for further replies.

bdw238

MIS
Dec 15, 2005
52
GB
On attempting to use the flock function in my perl script on Aix 5.3 server, and it does not lock correctly. What I am doing wrong?

sysopen($lockhandle,"/var/locks/test.lock",O_RDWR | O_CREAT,0664) || die ("Can Not open $LOCKFILE: $!\n");
unless (flock($lockhandle,LOCK_EX |LOCKNB)) {
exit 1;
}

Note this code works on Suse Linux


Brian
 
I'm on AIX 5.3 and it worked for me.

What part is not working? Is it dying on "Cannot open..." or is it exiting with a 1 inside your unless statement?
 
It is not locking the file. What should happen is process 1 of test.pl should continue normally and then any other attempt run of test.pl whilst the first test.ls process should exit value 1 as it has not obtained a write lock on /var/locks/test.lock.


Regards



Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top