unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Štěpán Němec" <stepnem@gmail.com>
To: Wolfgang Jenkner <wjenkner@inode.at>
Cc: 6771@debbugs.gnu.org
Subject: bug#6771: 24.0.50; Child process input isn't closed by process-send-eof; hangs indefinitely
Date: Fri, 10 Dec 2010 01:18:26 +0100	[thread overview]
Message-ID: <87ipz25vl9.fsf@gmail.com> (raw)
In-Reply-To: <85bp4whx4o.fsf@iznogoud.viz> (Wolfgang Jenkner's message of "Wed, 08 Dec 2010 20:18:35 +0100")

Wolfgang Jenkner <wjenkner@inode.at> writes:

> Jan Djärv <jan.h.d@swipnet.se> writes:
>
>> I enabled ICANON.  If there is a long line problem (i.e. a too long
>> line to send_process may only send a partial line), please write a bug
>> report for it with a way to reproduce it.  That way we can fix it.  I
>> have not seen any problem or been able to reproduce the long line
>> problem.
>
> FWIW, such a problem does exist in the wild.
>
> The UIM emacs bridge (see [1]) sometimes sends long lines of about 20k
> of ASCII characters to the uim-el-helper-agent subprocess.
>
> Now, on FreeBSD 8-STABLE the maximum total size of a tty (or pty) input
> queue is 1920 bytes, cf. tty_watermarks() in [2] and the discussion in
> [3].  For Linux, judging from a superficial glance at tty_buffer_alloc()
> in [4], the bound seems to be a more comfortable 65536 bytes.
>
> For a self-contained example of what happens on breaking this bound,
> evaluate the following form (adjust 1923 to taste) and observe that the
> process output buffer contains only ASCII BEL (\C-g) characters, which
> is (modulo bogus references to MAX_INPUT and MAX_CANON) what termios(4)
> documents (search for IMAXBEL), i.e., the pseudo-terminal rings :-)
>
> (let* ((buf (generate-new-buffer "cat-out"))
>        (proc (start-process "cat" buf "cat")))
>   (process-send-string proc (make-string 1923 ?x))
>   (process-send-string proc "\n")
>   (pop-to-buffer buf))
>
> Of course, if line discipline features are not needed, a pipe can be
> used as a work-around (and I intend to submit a patch in this sense to
> the UIM developers or else to the FreeBSD port maintainer, which is one
> reason why I wanted to have this issue documented here).

Although it would certainly be nice if this limitation disappeared,
using pipes instead is not necessarily a work-around -- it might simply
be the better solution for what you are doing, for other reasons as
well. As the Elisp manual puts it (info "(elisp)Asynchronous Processes"):

 -- Variable: process-connection-type
     This variable controls the type of device used to communicate with
     asynchronous subprocesses.  If it is non-`nil', then PTYs are
     used, when available.  Otherwise, pipes are used.

     PTYs are usually preferable for processes visible to the user, as
     in Shell mode, because they allow job control (`C-c', `C-z', etc.)
     to work between the process and its children, whereas pipes do
     not.  For subprocesses used for internal purposes by programs, it
     is often better to use a pipe, because they are more efficient.  In
     addition, the total number of PTYs is limited on many systems and
     it is good not to waste them.


  Štěpán





      reply	other threads:[~2010-12-10  0:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-01 16:19 bug#6771: 24.0.50; Child process input isn't closed by process-send-eof; hangs indefinitely Steve Purcell
2010-08-01 18:59 ` Óscar Fuentes
2010-08-02  7:06   ` Jan Djärv
2010-08-02 14:37     ` Óscar Fuentes
2010-08-02 18:27       ` Jan Djärv
2010-12-08 19:18     ` Wolfgang Jenkner
2010-12-10  0:18       ` Štěpán Němec [this message]

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87ipz25vl9.fsf@gmail.com \
    --to=stepnem@gmail.com \
    --cc=6771@debbugs.gnu.org \
    --cc=wjenkner@inode.at \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).