Re: How to make /dev/ttyACM0 (and friends) exclusive?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 2, 2019 at 1:45 PM <valdis.kletnieks@xxxxxx> wrote:
>
> On Fri, 01 Mar 2019 23:29:53 -0500, Jeffrey Walton said:
>
> > I cannot seem to open the device in exclusive mode. The current open
> > is (I also tried with O_EXCL):
> >
> >     int modem = open(device_path, O_RDWR | O_NOCTTY | O_SYNC);
>
> So what happens?  Does the open fail? If so, what does perror() say about it?
> Or does the open work but the flag is ignored?

Yes, both are allowed to open the device.

> Have you tried making the *other* program open it with O_EXCL so your
> caller-id program can't mess with its state?

Yes, I used O_EXCL . I have no control over other programs (this is
the reason I can't use something like a named semaphore or lock file).

I can say when I write a second test program that uses O_EXCL, it is
also allowed to open the device even when the device was already
opened O_EXCL.

I feel like I am missing something... Does Linux consider the modem a
shared resource instead of an exclusive resource? What use cases
support two different programs sending commands to the modem at the
same time?

Jeff

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux