Operating System - HP-UX
1843268 Members
4604 Online
110214 Solutions
New Discussion

Unlocking a locked file in Unix

 
SOLVED
Go to solution
Pankaj Agrawal
Occasional Advisor

Unlocking a locked file in Unix

I am trying to unlock a locked file using fcntl. Assuming that the file was successfully opened and locked (for writing), what all are the conditions whereby the unlocking call can fail ?
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Unlocking a locked file in Unix

All you have to do is man 2 fcntl and look under the sections called "ERRORS"; it explains this very well. When your fcntl returns -1, get the value of errno and compare that value to those listed in /usr/include/sys/errno.h. You now have the defines for the errno values listed in the man page. From that point, it's trivially easy.
If it ain't broke, I can fix that.