How to exclusive open serial device ?

How to open() device or file in that way
that next call to open() that device will fail ?

I try to open it in these ways:
dev_fd = open( “/dev/ser1”, O_RDWR | O_EXCL | O_NOCTTY | O_NONBLOCK );
dev_fd = sopen( “/dev/ser1”, O_RDWR | O_EXCL | O_NOCTTY | O_NONBLOCK, SH_DENYRW );

…but before close() I can open/sopen the same dev again without any errors (?!).

How to exclusive open() serial device ?

I’m afraid it is not possible.
In qnx4 there was dev_info() which allowed to get an “open_count” value. As far as i know there is no equivalent in qnx6.
You will probably have to implement this through another type of synchroniztion object like a named semaphore or similar concept.

(Also, the O_EXCL flag do not have meaning for serial device, it is used for regural files in conjunction with flag O_CREAT to make open() fail when the file already exists.)

I’m afraid it is not possible.

in any version of MS Windows it’s possible, but not in QNX ?!
:neutral_face:

and what about Unix / Linux (especialy Red Hat based systems) ?
RedHat open( serial_port ) always return ok ?
is there any posix function that make open exclusive ?