On Tue, Oct 23, 2001 at 12:24:45AM +0900, shun wrote:
> I was using "/dev/parport0" in a certain program .
> Then, I opened "/dev/parport0" by another program, and I called PPCLAIM.
> but, I didn't get any response.
Yes. Expected behaviour. The ioctl will block until the device is
released.
> I have a question.
> Is there any method of judging whether the device
> (for example, /dev/parport0 or /dev/parport1 or ...) is already used in
> another program?
Short answer: no.
Longer answer: yes, but it shouldn't block forever in the first
place. :-) The way to do it is to set an alarm with alarm(); if the
ioctl returns with errno==EINTR (because your alarm has fired), then
of course someone else is using the device.
But the 'someone else' who is using the device ought to release the
device fairly frequently (i.e. whenever it reasonably can). If it
can't at all, then it ought to use PPEXCL; failure to do so is a bug
in that driver.
If they use PPEXCL, your own PPCLAIM will fail (with ENXIO actually,
but perhaps EBUSY would have been better).
Is that any clearer?
Tim.
*/
-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2b29 : Mon Oct 22 2001 - 12:01:05 EDT