Call the open() API with an oflag of O_SHARE_NONE. (O_SHARE_NONE means
"I don't want to share my file with anyone") If the file is in use by
anyone, open() will fail with errno set to EBUSY.
Or, if you want a more sophisticated solution (one that will tell you
which jobs have the file open) use the Retrieve Object References
One advantage to using open() is that you will have exclusive use of the
object if open() returns successfully -- until you call close(), that
is. That's useful because it lets you use the update object without
fear of conflicting with another process.
With QP0LROR, you run the risk that the information you receive will be
out of date shortly after the API is finsihed, since another job may
open the file in the split second between you calling QP0LROR and the
time you do (whatever it is) to the object.
But, of course, the advantage to QP0LROR is that it tells you WHICH jobs
have it open, which is useful when you need to call the user and tell
them to get out of your file :)
Mike Roderick wrote:
Is there an API to determine if an IFS file is being used by another
I have used the access() API to see if the file exists, but I am not
sure if it will tell me if the file is locked.