From: Yann Droneaud <ydroneaud@opteya.com>
To: noloader@gmail.com, Greg KH <greg@kroah.com>
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: How to make /dev/ttyACM0 (and friends) exclusive?
Date: Mon, 04 Mar 2019 16:38:44 +0100 [thread overview]
Message-ID: <004695b63cb9510353902e0afef45ea8c57c8282.camel@opteya.com> (raw)
In-Reply-To: <CAH8yC8mDG-fzaM3LGMw-C=sPs04Xmfs_CW2mGDCu0W+8hDG=fQ@mail.gmail.com>
Hi,
Le lundi 04 mars 2019 à 08:04 -0500, Jeffrey Walton a écrit :
> On Sun, Mar 3, 2019 at 6:00 AM Greg KH <greg@kroah.com> wrote:
> >
> > On Sun, Mar 03, 2019 at 03:55:44AM -0500, Jeffrey Walton wrote:
> > > ...
> >
> > Again, go delete modem manager off of your system, it is the thing that
> > keeps opening the port up to see if you have made a valid connection on
> > the device or not. If you write your own program to talk to the device,
> > modem manager is not needed at all, and is known to cause this problem.
>
> Thanks Greg. I deleted modem manager, then ran two instances of my
> program. Both opened the device with O_EXCL, and both opens succeeded.
> They proceeded to much with one another's state.
>
http://man7.org/linux/man-pages/man2/open.2.html
"In general, the behavior of O_EXCL is undefined if it is used
without O_CREAT. There is one exception: on Linux 2.6 and later,
O_EXCL can be used without O_CREAT if pathname refers to a block
device. If the block device is in use by the system (e.g., mounted),
open() fails with the error EBUSY."
O_EXCL is intended to be used to prevent opening an existing file. Said
differently, it's used to ensure a new file is created, useful to
prevent race condition, where multiple processes compete to create a
file. For example think of temporary file created with random name.
Regards
--
Yann Droneaud
OPTEYA
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
next prev parent reply other threads:[~2019-03-04 15:39 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
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 [this message]
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=004695b63cb9510353902e0afef45ea8c57c8282.camel@opteya.com \
--to=ydroneaud@opteya.com \
--cc=greg@kroah.com \
--cc=kernelnewbies@kernelnewbies.org \
--cc=noloader@gmail.com \
/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).