From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E3E2C43381 for ; Sat, 2 Mar 2019 19:37:10 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E126E20830 for ; Sat, 2 Mar 2019 19:37:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PB8ZZUOG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E126E20830 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.91) (envelope-from ) id 1h0AR7-00030B-HC; Sat, 02 Mar 2019 14:36:41 -0500 Received: from mail-it1-x12a.google.com ([2607:f8b0:4864:20::12a]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.91) (envelope-from ) id 1h0AR4-000305-VZ for kernelnewbies@kernelnewbies.org; Sat, 02 Mar 2019 14:36:39 -0500 Received: by mail-it1-x12a.google.com with SMTP id l15so1971081iti.4 for ; Sat, 02 Mar 2019 11:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:reply-to:from:date:message-id :subject:to:cc; bh=3AxxQnWW4XyDcVtXHnbhqyij+H/OVwdd8JVG/Dxgx3I=; b=PB8ZZUOGVqikA68Pl0Lj9bPKbr+5tfWxlUGuk1kVuXm5Aq8Qk0tPi7iRsrAsDNmWBL 4Z8PZNCAwpMdvwebw7fBf4fgmsMfabxd6Viz/Zn/jmPOBNnmUCLZqWCC7n3DOyh9FPBd jkApOwSraEyLZuQeECA2RRk2b5OlkNtFXAw562qJpjHOdaaFhtm0JQvzFhNvTtbjomXl ugkgrJFZBAbSCNQkVllsX+Zs7jgyg/eP4/M4z2bahJteDmRsaYDulMWawjsOxCsyEWWJ oYPd+kNaFa6172jL27PqHygErwAWxldEhPGYv2wTvN7UgHf1+YtaNAsY+SJo3UZXIJz+ qjBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=3AxxQnWW4XyDcVtXHnbhqyij+H/OVwdd8JVG/Dxgx3I=; b=KFjx4zWfMRdX1c0ykVPeUzkKQUOzs5hv/kG1sY0IkF9aasZwAoubZT8R0s6J7eXnf/ ylUDTbdO4C3+6ETI/fYGspj2fYYeEjuejBaAwB7nQyugXnNL7ISsIWDNDL+X4ABS4uww KWwYUVrP4xLilMIA+UpQSy33t0WMTs3nAhtDWgtDCwebKeCSD3FUReQHOCUGG7HuzTKI WnrRG3zaK4nBbtXL0SxDhOQRvjGCibbKhWuIu96FYsWlu0pQSsEms5pac8h1Erhb8pcd KgjvoC9AXBsAt1aAdMlb7XZoCduFafloLTER3YZoJqvbawkRDRCRxbRhegKrXDUppvAx wnHw== X-Gm-Message-State: APjAAAWcspXITlizN1SQlfagW4dWTTjVMCgluq40wXr9jJUaDoJRIsow 2KMhaUqpqpJxcKaom9ZUGIZy1lGSJmM6b6Hr5wlezg97 X-Google-Smtp-Source: AHgI3IaIT7fbH0MF55RGIPCjsb9ElrQHlk+fqJGqSDUZPZnlvzqw0s+q1S4uhZgmGz/u+AjWnFCNrQI8roZCEs4NMZ8= X-Received: by 2002:a24:3b0a:: with SMTP id c10mr5824876ita.10.1551555396740; Sat, 02 Mar 2019 11:36:36 -0800 (PST) MIME-Version: 1.0 References: <3824.1551552333@turing-police> In-Reply-To: <3824.1551552333@turing-police> From: Jeffrey Walton Date: Sat, 2 Mar 2019 14:36:12 -0500 Message-ID: Subject: Re: How to make /dev/ttyACM0 (and friends) exclusive? To: Valdis Kletnieks Cc: kernelnewbies X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: noloader@gmail.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Sat, Mar 2, 2019 at 1:45 PM 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