From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Peter Newsgroups: gmane.emacs.devel Subject: Re: Reading from pipes directly with a process-filter Date: Fri, 13 Jan 2023 22:51:04 +0100 Message-ID: <87wn5q6r3r.fsf@nexoid.at> References: <87zgam6yy6.fsf@nexoid.at> <83wn5q8bk1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24325"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Jan 13 22:51:53 2023 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pGRxp-000664-97 for ged-emacs-devel@m.gmane-mx.org; Fri, 13 Jan 2023 22:51:53 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGRxE-00078i-FG; Fri, 13 Jan 2023 16:51:16 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGRxC-00078T-FC for emacs-devel@gnu.org; Fri, 13 Jan 2023 16:51:14 -0500 Original-Received: from www.nexoid.at ([178.79.130.240] helo=nexoid.at) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGRxA-0000rE-G5; Fri, 13 Jan 2023 16:51:14 -0500 DKIM-Filter: OpenDKIM Filter v2.10.3 nexoid.at 700EA25EF2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexoid.at; s=mail; t=1673646665; bh=wOuQdl6dimzZjtHzW6e40mR4arVY/raAQKYrkpD5RkM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=dadNNIhiygMbDHCzINdQZTkq2Zw7YFOXznn4YdPqw7jQL9jQxrThvGbxcxJQ75fh7 vCg10/VXeW1uzeYOliDnZRdcC88oSw6qbXDfaDfUf/Ja08uj8tReQVWA9M7QXPslhc bwTPINe+RARDWhHpMmhdI6GH+bcpX/nKzWEZ6APD+T3oGVPXfRou2OvBo2ic4s/KVW EAhit1gRIYcUFgfsM3kZYq6BLVOXuZtU6V8lufA+zZo2eaanT6duJ+F/GJElbUvh23 87CsDVT7j0uXEUhqc/sKHgZqOxH6bs8Wfr7x1E39LYv3y8YO+pNKjzI0soO8NBeCnF 52j6bCid2O8PA== In-Reply-To: <83wn5q8bk1.fsf@gnu.org> Received-SPF: none client-ip=178.79.130.240; envelope-from=emacs@nexoid.at; helo=nexoid.at X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:302402 Archived-At: >> I've been slowly sliding into using Emacs more and more like a Lisp OS, >> so one thing that has come up is directly reading data from pipes or >> special devices (like /dev/input/event...). I can do that fine by >> running `start-process' with `cat /dev/input/event..', however that >> seems a bit wasteful. Is there any way to *directly* open such a file >> and put a process-filter in front of it? > > Did you try to use make-pipe-process? No, but from my understanding, this will also not read the file directly, but run an extra process. >> Semi-relatedly, is there any support for `fnctl' or `ioctl' in elisp, so >> that I could even *write* to those special devices? > > Doesn't a simple 'write' (a.k.a. write-region in Emacs) work? If not, > can you show a recipe that fails with all the details? For example https://www.kernel.org/doc/html/v4.12/input/uinput.html shows how to write events to uinput. The function emit does the writing (the encoding can easily be done with bindat in Emacs), however it isn't sufficient to just *write* events, but some metadata must be set via ioctl (yea, "everything is a file" ... except for so many things...). This is not a "normal" use-case for Emacs, however I've been playing around with running Emacs on the Pinephone, and this would help with the vibrator for notifications, for example. Of course this could also be done in C code from a module, but if Emacs already somehow has support for doing this "directly", that'd be even greater ;) Thanks for taking the time to think about this! Greetings, Peter