From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Using file descriptors in Emacs Date: Sat, 10 Sep 2016 10:12:42 +0300 Message-ID: <83oa3w8byt.fsf@gnu.org> References: <1465262706-5229-1-git-send-email-sbaugh@catern.com> <87twfevqu7.fsf@earth.catern.com> <87pood5fee.fsf@earth.catern.com> <834m5p83yy.fsf@gnu.org> <877fal56zh.fsf@earth.catern.com> <83d1kcaowk.fsf@gnu.org> <8737l86glg.fsf@earth.catern.com> <837fakan8b.fsf@gnu.org> <87r38s4xmv.fsf@earth.catern.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1473491586 27964 195.159.176.226 (10 Sep 2016 07:13:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 10 Sep 2016 07:13:06 +0000 (UTC) Cc: emacs-devel@gnu.org To: sbaugh@catern.com Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 10 09:13:03 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bicTF-0006dW-Bk for ged-emacs-devel@m.gmane.org; Sat, 10 Sep 2016 09:13:01 +0200 Original-Received: from localhost ([::1]:33449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bicTC-00007n-Us for ged-emacs-devel@m.gmane.org; Sat, 10 Sep 2016 03:12:58 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bicT6-00007O-KS for emacs-devel@gnu.org; Sat, 10 Sep 2016 03:12:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bicT2-0002KU-Ah for emacs-devel@gnu.org; Sat, 10 Sep 2016 03:12:51 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bicT2-0002KM-7b; Sat, 10 Sep 2016 03:12:48 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1924 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1bicSz-00019M-3D; Sat, 10 Sep 2016 03:12:46 -0400 In-reply-to: <87r38s4xmv.fsf@earth.catern.com> (sbaugh@catern.com) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:207351 Archived-At: > From: sbaugh@catern.com > Date: Fri, 09 Sep 2016 16:38:16 -0400 > > >> Not as far as I know - what in my patches suggests that I need a pipe? > > > > A pipe is a set of 2 file descriptors between 2 programs, one of the > > descriptors is used for reading by one program and writing by the > > other, the other descriptor used similarly in the opposite direction. > > Isn't that what you set up? > > > > If not, then I must be missing something, so please describe the data > > flow between emacsclient, emacs server, and the external program. > > There is not necessarily any external program. Even emacsclient can exit > just fine once the file descriptors are passed in and a process object > created from them. > > Once a process object P is created, the data flow is as follows: > > When emacs writes to P, emacs is directly writing to the file descriptor > that emacsclient had as its stdout. It is literally calling "write" on > the file descriptor that was/is emacsclient's stdout. > > When emacs reads from P, emacs is directly reading from the file > descriptor that emacsclient had as its stdin. It is literally calling > "read" on the file descriptor that was/is emacsclient's stdin. Emacs doesn't normally read or write from/to file descriptors. The only features that do such things are communications with subprocesses, which could be either local subprocesses (in which case Emacs talks to them via a pipe) or remote processes (in which case we use network or serial connections). One other kind of feature that uses file descriptors is external data sources, such as D-Bus and inotify, which are a kind of local process (the OS kernel or some other daemon) that doesn't need to be run by Emacs, only communicated with. As we already have a framework for all of the above, what other kinds of descriptors, which don't fit into the framework, would we like to have? > For example I would like to bring eshell up to par with other Unix > shells, and the ability to manipulate file descriptors directly is > pretty much required for that. Please elaborate: how are file descriptors required for that? A shell needs to pass file descriptors to the subprocesses it invokes, which AFAIK we already do in the primitives that invoke subprocesses. What else is needed, and how does the feature you propose fit into that?