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.bugs Subject: bug#56025: [PATCH v4] 29.0.50; em-extpipe-test-2 times out on EMBA and Cygwin Date: Sun, 24 Jul 2022 12:47:36 +0300 Message-ID: <834jz6hmfb.fsf@gnu.org> References: <8e21db9c-0100-998e-f280-81304e7ff61a@cornell.edu> <8735frmjrr.fsf@athena.silentflame.com> <4676f52c-4758-38df-f0f4-dbcb5d848c1b@gmail.com> <8735fr2kq6.fsf@melete.silentflame.com> <10cf6a90-f86a-b0df-4dc2-c258b7494158@gmail.com> <18e79c02-3a2a-77d1-3798-33711f52d6b9@cornell.edu> <19c66901-2eeb-1f40-17a4-4ed54827e065@gmail.com> <5990de80-63a5-ac9b-1a11-c814aa9e38f2@gmail.com> <3779ea08-f481-5fb5-3257-ca9fa7c604bc@cornell.edu> <60cf587b-5d83-31d6-f0af-56979b221425@gmail.com> <6725161c-1d45-8ded-5d75-aa1a74c9b3ed@gmail.com> <91cb3365-119c-8f3a-4c7b-5c83792dcf88@cornell.edu> <73ed3965-3dfb-75e9-eab1-389507b7112d@gmail.com> <7056ea9f-a55d-28b7-52cf-caca7a9053a5@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31687"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 56025@debbugs.gnu.org, spwhitton@email.arizona.edu, kbrown@cornell.edu To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jul 24 11:48:35 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1oFYDz-00083R-Ae for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Jul 2022 11:48:35 +0200 Original-Received: from localhost ([::1]:42234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oFYDx-0003Ex-Sx for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Jul 2022 05:48:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38824) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFYDS-0003Eb-I3 for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2022 05:48:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:57148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oFYDR-0001uL-P9 for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2022 05:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oFYDR-0004lo-IX for bug-gnu-emacs@gnu.org; Sun, 24 Jul 2022 05:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Jul 2022 09:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56025 X-GNU-PR-Package: emacs Original-Received: via spool by 56025-submit@debbugs.gnu.org id=B56025.165865606918252 (code B ref 56025); Sun, 24 Jul 2022 09:48:01 +0000 Original-Received: (at 56025) by debbugs.gnu.org; 24 Jul 2022 09:47:49 +0000 Original-Received: from localhost ([127.0.0.1]:46897 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFYDE-0004kG-JZ for submit@debbugs.gnu.org; Sun, 24 Jul 2022 05:47:49 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:54122) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oFYDB-0004jL-Vc for 56025@debbugs.gnu.org; Sun, 24 Jul 2022 05:47:47 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:55948) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oFYD3-0001td-R3; Sun, 24 Jul 2022 05:47:37 -0400 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=lVfONBgYAjUO6YNg1j/FPS4eEraRF1YrTXZinpWEcnM=; b=QGAQIDhwaFbG kDHc/m6KkPhVw1Wyhkd7yVkOyc4hBVdq3a0vRc1DtzxqdjyyXOfjkoIaaFoIuKtbNbBwsGQTVbXyL D8WTIXXD21uZPuWrUghgFmh7wewFjHcPPezNVt+KGXxSvMs6uqSh5KRWDC3bJ/uzezhNJCN0v3vXD n+p1ws7sxhv8QQQNXPhoYpNc2m4KKiCMsjNtkOEkRHB7d5N2QQEtgwKbG+NMFLBlinDOjT883GfgB ZpDz6+xt+SEssX1gobNf4oZuZuv7qe5qk6S4c8oYwIklYutcUs4n7qQosEUDCvTqRSzR3F0Ce6B8Q rLpOSwd4vi1mfc+P+JcbRg==; Original-Received: from [87.69.77.57] (port=1538 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 1oFYD3-0002Iy-AV; Sun, 24 Jul 2022 05:47:37 -0400 In-Reply-To: <7056ea9f-a55d-28b7-52cf-caca7a9053a5@gmail.com> (message from Jim Porter on Sat, 23 Jul 2022 22:29:28 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:237828 Archived-At: > From: Jim Porter > Cc: larsi@gnus.org, 56025@debbugs.gnu.org > Date: Sat, 23 Jul 2022 22:29:28 -0700 > > -@defun process-tty-name process > +@defun process-tty-name process &optional stream > This function returns the terminal name that @var{process} is using for > its communication with Emacs---or @code{nil} if it is using pipes > instead of a pty (see @code{process-connection-type} in > -@ref{Asynchronous Processes}). If @var{process} represents a program > -running on a remote host, the terminal name used by that program on > -the remote host is provided as process property @code{remote-tty}. If > -@var{process} represents a network, serial, or pipe connection, the > -value is @code{nil}. > +@ref{Asynchronous Processes}). If @var{stream} is one of @code{stdin}, > +@code{stdout}, or @code{stderr}, this function returns the terminal > +name (or @code{nil}, as above) that @var{process} uses for that stream > +specifically. You can use this to determine whether a particular > +stream uses a pipe or a pty. This text doesn't tell what happens if STREAM is nil or omitted. > +If @var{process} represents a program running on a remote host, the > +terminal name used by that program on the remote host is provided as > +process property @code{remote-tty}. If @var{process} represents a > +network, serial, or pipe connection, the value is @code{nil}. If the previous paragraph is only for local subprocesses, the text there should say so. > @end defun > > @defun process-coding-system process > diff --git a/etc/NEWS b/etc/NEWS > index dc79f0826a..23777d349e 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -3198,7 +3198,10 @@ invocation. Such shells are POSIX conformant by default. > ** 'make-process' can set connection type independently for input and output. > When calling 'make-process', communication via pty can be enabled > selectively for just input or output by passing a cons cell for > -':connection-type', e.g. '(pipe . pty)'. > +':connection-type', e.g. '(pipe . pty)'. When examining a process > +later, you can determine whether a particular stream for a process > +uses a pty by passing one of 'stdin', 'stdout', or 'stderr' as the > +second argument to 'process-tty-name'. > > +++ > ** 'signal-process' now consults the list 'signal-process-functions'. > diff --git a/lisp/eshell/esh-io.el b/lisp/eshell/esh-io.el > index c035890ddf..68e52a2c9c 100644 > --- a/lisp/eshell/esh-io.el > +++ b/lisp/eshell/esh-io.el > @@ -276,18 +276,21 @@ eshell-close-target > ;; If we're redirecting to a process (via a pipe, or process > ;; redirection), send it EOF so that it knows we're finished. > ((eshell-processp target) > - ;; According to POSIX.1-2017, section 11.1.9, sending EOF causes > - ;; all bytes waiting to be read to be sent to the process > - ;; immediately. Thus, if there are any bytes waiting, we need to > - ;; send EOF twice: once to flush the buffer, and a second time to > - ;; cause the next read() to return a size of 0, indicating > - ;; end-of-file to the reading process. However, some platforms > - ;; (e.g. Solaris) actually require sending a *third* EOF. Since > - ;; sending extra EOFs while the process is running shouldn't break > - ;; anything, we'll just send the maximum we'd ever need. See > - ;; bug#56025 for further details. > - (let ((i 0)) > - (while (and (<= (cl-incf i) 3) > + ;; According to POSIX.1-2017, section 11.1.9, when communicating > + ;; via terminal, sending EOF causes all bytes waiting to be read > + ;; to be sent to the process immediately. Thus, if there are any > + ;; bytes waiting, we need to send EOF twice: once to flush the > + ;; buffer, and a second time to cause the next read() to return a > + ;; size of 0, indicating end-of-file to the reading process. > + ;; However, some platforms (e.g. Solaris) actually require sending > + ;; a *third* EOF. Since sending extra EOFs while the process is > + ;; running are a no-op, we'll just send the maximum we'd ever > + ;; need. See bug#56025 for further details. > + (let ((i 0) > + ;; Only call `process-send-eof' once if communicating via a > + ;; pipe (in truth, this just closes the pipe). > + (max-attempts (if (process-tty-name target 'stdin) 3 1))) > + (while (and (<= (cl-incf i) max-attempts) > (eq (process-status target) 'run)) > (process-send-eof target)))) > > diff --git a/src/process.c b/src/process.c > index da5e9cb182..adc508156f 100644 > --- a/src/process.c > +++ b/src/process.c > @@ -1243,14 +1243,29 @@ DEFUN ("process-command", Fprocess_command, Sprocess_command, 1, 1, 0, > return XPROCESS (process)->command; > } > > -DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 1, 0, > +DEFUN ("process-tty-name", Fprocess_tty_name, Sprocess_tty_name, 1, 2, 0, > doc: /* Return the name of the terminal PROCESS uses, or nil if none. > This is the terminal that the process itself reads and writes on, > -not the name of the pty that Emacs uses to talk with that terminal. */) > - (register Lisp_Object process) > +not the name of the pty that Emacs uses to talk with that terminal. > + > +If STREAM is one of `stdin', `stdout', or `stderr', return the name of > +the terminal PROCESS uses for that stream. This can be used to detect > +whether a particular stream is connected via a pipe or a pty. */) > + (register Lisp_Object process, Lisp_Object stream) Same here: the call without the optional argument returns something whose relation to the value when STREAM is non-nil is not clear from the doc string. Thanks.