How to make /dev/ttyACM0 (and friends) exclusive?
Greg KH
greg at kroah.com
Sat Mar 2 02:50:07 EST 2019
On Fri, Mar 01, 2019 at 11:29:53PM -0500, Jeffrey Walton wrote:
> Hi Everyone,
>
> I'm trying to trackdown a problem using my dialup modem. I have a
> program that opens the modem and watches caller id's. It flashes the
> hook when a telemarketer calls. It works well until...
>
> When another program opens the modem then my program starts reading
> intermittent responses intended for the other program.
>
> 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);
>
> I'm not sure if it because udev configures the device incorrectly or
> the kernel driver is configured incorrectly. Or maybe it is impossible
> to do.
This isn't a kernel thing, it is a userspace configuration issue. Just
change the permissions of the device node such that only your one
program can open it. Or, once you open it, change the permissions such
that no one else can open it.
Or better yet, uninstall modem manager, that's what is probably opening
up the device at random points in time :)
good luck!
greg k-h
More information about the Kernelnewbies
mailing list