How to make /dev/ttyACM0 (and friends) exclusive?
Greg KH
greg at kroah.com
Mon Mar 4 08:20:11 EST 2019
On Mon, Mar 04, 2019 at 08:04:23AM -0500, Jeffrey Walton wrote:
> On Sun, Mar 3, 2019 at 6:00 AM Greg KH <greg at 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.
Yes, don't do that :)
> I don't think modem manager is the problem here.
The problem is your userspace is trying to open a device node twice
without being _very_ careful about it :)
> The first problem is the way this device is setup. An exclusive
> resource is being treated as a shared resource. The second problem is
> open silently ignores flags. Epic fail.
character device nodes do not support O_EXCL, only block device nodes
do in kernels newer than 2.6.
Again, the kernel is working just fine the only "failure" is a lack of
reading the man page for open(2) fully :)
greg k-h
More information about the Kernelnewbies
mailing list