How to open a device for exclusive access?

Steven W. Orr steveo at syslang.net
Fri Jul 13 23:10:04 EDT 2007


I have a device (it happens to be a somewhat exotic serial port) which is 
managed by a server process. I want my server to detect whether another 
instance of that server already has that device open. I'm guaranteed that 
no other program other that the one I'm in control of is capable of 
opening that particular device.

I was hoping that I could maybe not have to use either mandatory or 
advisory file locking. I have tried O_EXCL | O_RDWR | O_NONBLOCK when 
opening the device node hoping to get back EBUSY or EAGAIN.

Does anyone know if I'm SOOL or is there a way to do it?

TIA

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


More information about the gnhlug-discuss mailing list