From: Jeffrey Walton <noloader@gmail.com>
To: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: How to make /dev/ttyACM0 (and friends) exclusive?
Date: Sat, 2 Mar 2019 14:36:12 -0500 [thread overview]
Message-ID: <CAH8yC8kkwZLD+get-V-kp1jYMmG7ovYTnQVJdis-DdCyVGTzdw@mail.gmail.com> (raw)
In-Reply-To: <3824.1551552333@turing-police>
On Sat, Mar 2, 2019 at 1:45 PM <valdis.kletnieks@vt.edu> 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@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next prev parent reply other threads:[~2019-03-02 19:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-02 4:29 How to make /dev/ttyACM0 (and friends) exclusive? Jeffrey Walton
2019-03-02 7:50 ` Greg KH
2019-03-02 18:45 ` valdis.kletnieks
2019-03-02 19:36 ` Jeffrey Walton [this message]
2019-03-03 5:55 ` valdis.kletnieks
2019-03-03 8:55 ` Jeffrey Walton
2019-03-03 11:00 ` Greg KH
2019-03-04 13:04 ` Jeffrey Walton
2019-03-04 13:20 ` Greg KH
2019-03-04 15:38 ` Yann Droneaud
2019-03-04 22:01 ` valdis.kletnieks
2020-10-06 20:41 ` Daniel Santos
2020-10-11 14:52 ` linux lover
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAH8yC8kkwZLD+get-V-kp1jYMmG7ovYTnQVJdis-DdCyVGTzdw@mail.gmail.com \
--to=noloader@gmail.com \
--cc=kernelnewbies@kernelnewbies.org \
--cc=valdis.kletnieks@vt.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).