all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: sbaugh@catern.com
To: emacs-devel@gnu.org
Subject: Re: Using file descriptors in Emacs
Date: Sun, 11 Sep 2016 12:57:25 -0400	[thread overview]
Message-ID: <87zinez85m.fsf@earth.catern.com> (raw)
In-Reply-To: 8337l6bdcl.fsf@gnu.org

Eli Zaretskii <eliz@gnu.org> writes:
>> From: sbaugh@catern.com
>> Date: Sun, 11 Sep 2016 12:00:21 -0400
>> 
>> I suppose one could add the capability to pass in a process object as
>> the source of input for a new process object. This could be implemented
>> by forcing the passed-in process object to a state where it does not
>> have (and cannot have) a process-filter function. Then the file
>> descriptor used for input to the passed-in process object could be
>> manipulated appropriately to make it the stdin of the new process
>> object. The new process object in turn will be in a special state where
>> it cannot accept input from Emacs.
>> 
>> Likewise for the capability to pass in a process object as the
>> destination for a program's output, instead of a process-filter, and the
>> capability to redirect arbitrary file descriptor numbers to point at
>> process objects (or other file descriptors).
>> 
>> Then also it is necessary to handle redirecting to and from files
>> without going through Emacs. That could be done by creating a new kind
>> of process object which is created by opening a file, and then that can
>> be passed in in the way I describe above.
>
> Yes, something like that.
>
>> But to me that sounds somewhat unnatural for the process API.
>
> To me it sounds most natural.  All of our APIs in this area are like
> that.

OK, that works for me. I guess it's not really different from the API I
would have constructed for file descriptors.

I can hack up some patches for this. Or maybe people have more thoughts
on the appropriate API first?

> Btw, running a pipe of processes raises another issue, unrelated to
> file descriptors: we would need a way to make sure the processes do
> not start running until all the redirections are set up, otherwise
> some of them will die with SIGPIPE or somesuch.

No, SIGPIPE will only happen when the read end of the pipe is no longer
open anywhere. If a process is writing to a pipe for which the read end
of the pipe has not yet been passed to a subprocess, that process will
just block, since we will still have the read end of the pipe open in
the Emacs process. We would only close the read end of the pipe after
forking, and the fork will make a copy of the read end of the pipe so it
will still be open even while the redirection is in process.




  reply	other threads:[~2016-09-11 16:57 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-07  1:25 Teaching emacsclient to act as a pager, and more Spencer Baugh
2016-06-07  1:25 ` [PATCH 1/5] process: add features for direct use of FDs Spencer Baugh
2016-06-07  1:25 ` [PATCH 2/5] server.el: accept FDs from emacsclient Spencer Baugh
2016-06-07  1:25 ` [PATCH 3/5] emacsclient: support passing stdin/out/err to emacs Spencer Baugh
2016-06-07  1:25 ` [PATCH 4/5] server: add pager tapping and show-active Spencer Baugh
2016-06-07  1:25 ` [PATCH 5/5] emacsclient: add extra-quiet mode Spencer Baugh
2016-06-08 15:51 ` Teaching emacsclient to act as a pager, and more Tassilo Horn
2016-06-08 16:13   ` Anders Lindgren
2016-06-08 17:30     ` Tassilo Horn
2016-06-09  0:25   ` raman
2016-06-09 11:31 ` H. Dieter Wilhelm
2016-06-27 22:42 ` Ole JørgenBrønner
2016-07-24 18:22 ` sbaugh
2016-09-09 13:42   ` Noam Postavsky
2016-09-09 14:14     ` sbaugh
2016-09-09 14:59       ` Stefan Monnier
2016-09-09 15:58         ` sbaugh
2016-09-09 19:26           ` Stefan Monnier
2016-09-09 19:42             ` Eli Zaretskii
2016-09-09 21:13             ` sbaugh
2016-09-10  6:37               ` Using file descriptors in Emacs (was: Teaching emacsclient to act as a pager, and more) Eli Zaretskii
2016-09-10 20:15             ` Teaching emacsclient to act as a pager, and more sbaugh
2016-09-11  2:11               ` Leo Liu
2018-02-16 23:14               ` Kaushal Modi
2018-02-17 15:46                 ` Göktuğ Kayaalp
2016-09-09 15:53       ` Eli Zaretskii
2016-09-09 17:16         ` sbaugh
2016-09-09 18:50           ` Eli Zaretskii
2016-09-09 19:03             ` sbaugh
2016-09-09 19:26               ` Eli Zaretskii
2016-09-09 20:38                 ` sbaugh
2016-09-10  7:12                   ` Using file descriptors in Emacs Eli Zaretskii
2016-09-10 14:28                     ` sbaugh
2016-09-11 15:28                       ` Eli Zaretskii
2016-09-11 16:00                         ` sbaugh
2016-09-11 16:39                           ` Eli Zaretskii
2016-09-11 16:57                             ` sbaugh [this message]
2016-09-11 17:13                               ` Eli Zaretskii
2016-09-12 15:40                               ` Davis Herring
2016-09-09 13:27 ` Teaching emacsclient to act as a pager, and more sbaugh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zinez85m.fsf@earth.catern.com \
    --to=sbaugh@catern.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.