How to avoid multiple application accessing same port.

Hi All,
I am using standard serial driver devc-ser8250 for serial communication with my hardware. I have observed that if first application is accessing port say /dev/ser1 then driver gives the handle for port sending /receive. But if another application also trys to open same port ( /dev/ser1) then driver gives handle for same port.
How to avoid multiple application access to same port. Also would like to inform that devc-ser8250 driver is based on io-char library. So developer does not have much control on code (there is no open(), close() etc calls in code).

Hi All,
On Windows, once a port is open by one application, no other application have access to the same port. I too have observed in case of QNX, its not possible. Any explanation for this is highly appreciated.

Multiple threads or processes opening a device multiple times is correct and important Posix behavior. If you want to prevent this, you need a mechanism to prevent conflicts.

In QNX4 there was a way to determined if the serial port was already opened. I guess in QNX6 one could do what pidin fd does to determined if someone else has opened the port.