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 (QP0LROR) API.
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/apis/qp0lror.htm

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
process

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.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].