From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Reading from pipes directly with a process-filter Date: Sat, 14 Jan 2023 08:56:46 +0200 Message-ID: <83v8l98uz5.fsf@gnu.org> References: <87zgam6yy6.fsf@nexoid.at> <83wn5q8bk1.fsf@gnu.org> <87wn5q6r3r.fsf@nexoid.at> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3845"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Peter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 14 07:57:35 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 1pGaTv-0000ks-3V for ged-emacs-devel@m.gmane-mx.org; Sat, 14 Jan 2023 07:57:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGaTB-000232-6o; Sat, 14 Jan 2023 01:56:49 -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 1pGaT8-00022c-HQ for emacs-devel@gnu.org; Sat, 14 Jan 2023 01:56:47 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGaT7-0001TG-JE; Sat, 14 Jan 2023 01:56:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=lx9u0ztIOgDwxdtDte/WwC7nB514UryZ5rEJI0Kn9EI=; b=P4yGwBH7nq5u BUWs35K6VZzfb+RYAtSQQKUanuQ0jrtfBIWN/6B9SLFk0aGS8pgUuRSRDibjJP9ElloKkxVpxWcSe IxX7mjtu7BpIFpT0laqUHVrJgOX++Hp5cify5Tke49l3xQoWsIzSOPLKUqOGlSBkT909HGJ1J9PTt Wod8TTXseXnaj3SJjf1SXwbXm9zk8nWG58WtPltMsNNWmt34fzxqxTBFYGvTv5QLtpZqTUrx9VKnX InsRkfZlqcphODMn1tAV4Fg3wNbQoPiMY/wMfA6s6K6AWHbd+4CEq+oos36gcUskqxzXlJi0CGxxb PG/peKhJsOyYo+rvPb2TwA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pGaT7-0001JV-1v; Sat, 14 Jan 2023 01:56:45 -0500 In-Reply-To: <87wn5q6r3r.fsf@nexoid.at> (message from Peter on Fri, 13 Jan 2023 22:51:04 +0100) 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:302408 Archived-At: > From: Peter > Cc: emacs-devel@gnu.org > Date: Fri, 13 Jan 2023 22:51:04 +0100 > > >> 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. I don't think I understand what you are saying. make-pipe-process doesn't create any OS-level process, it creates only an Emacs process object, similarly to what make-network-process does. > >> 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 ;) Sounds like a job for a dynamic module, not for something that has to be in the Emacs core.