GNU bug report logs -
#54136
29.0.50; Eshell emits extra prompts when killing processes in some cases
Previous Next
Reported by: Jim Porter <jporterbugs <at> gmail.com>
Date: Thu, 24 Feb 2022 05:12:01 UTC
Severity: normal
Found in version 29.0.50
Fixed in version 29.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54136 in the body.
You can then email your comments to 54136 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Thu, 24 Feb 2022 05:12:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Jim Porter <jporterbugs <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 24 Feb 2022 05:12:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
(Patch forthcoming; I'm just getting a bug number first...)
Sometimes, when killing processes in Eshell (especially in pipelines),
Eshell will emit *two* prompts instead of one. Starting with "emacs -Q
--eval '(eshell)'...
Problem #1: Killing pipelines
-----------------------------
~ $ sh -c 'while true; do echo y; sleep 1; done' | sh -c 'while true;
do read NAME; done'
C-c C-c ; or C-c C-k
The result is ("|" is the point):
interrupted
~ $
~ $ |
What's happening here is one prompt is being emitted per process in the
pipeline. It should only emit one prompt total.
Problem #2: Killing the head of a pipeline
------------------------------------------
~ $ sh -c 'while true; do sleep 1; done' | sh -c 'while read NAME; do
echo =${NAME}=; done'
M-: (kill-process (eshell-head-process)) RET
The result is:
~ $ =killed=
|
In this case, Eshell writes the head process's exit status message to
its stdout handle (i.e. to the tail process's stdin). It should either
write directly to the terminal, or not write at all. I went with the
latter, since the former would mean that we write "interrupted" N times
in problem #1 above.
Problem #3: Killing a background process
----------------------------------------
~ $ sh -c 'while true; do sleep 1; done' &
This outputs, as expected:
[sh] 12345
~ $
Now call `(kill-process (caar eshell-process-list))'. The result is:
~ $ killed
~ $ |
Here, Eshell writes the exit status to the terminal, but does so in an
awkward spot, and then emits a new prompt. I think it should just avoid
printing anything here. Information about the killed process is also
shown in the minibuffer, so the user already has a place (and a better
one at that!) to see what happened.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Thu, 24 Feb 2022 05:17:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 54136 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2/23/2022 9:11 PM, Jim Porter wrote:
> (Patch forthcoming; I'm just getting a bug number first...)
Ok, here's the patch with some tests.
[0001-Don-t-superfluously-emit-prompts-when-terminating-pr.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Thu, 24 Feb 2022 09:36:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 54136 <at> debbugs.gnu.org (full text, mbox):
Jim Porter <jporterbugs <at> gmail.com> writes:
> Ok, here's the patch with some tests.
Thanks; pushed to Emacs 29.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
bug marked as fixed in version 29.1, send any further explanations to
54136 <at> debbugs.gnu.org and Jim Porter <jporterbugs <at> gmail.com>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 24 Feb 2022 09:36:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Thu, 24 Feb 2022 11:04:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 54136 <at> debbugs.gnu.org (full text, mbox):
> From: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Thu, 24 Feb 2022 10:35:32 +0100
> Cc: 54136 <at> debbugs.gnu.org
>
> Jim Porter <jporterbugs <at> gmail.com> writes:
>
> > Ok, here's the patch with some tests.
>
> Thanks; pushed to Emacs 29.
The new tests fail on MS-Windows. Does the patch below look right?
I'm quite sure about the "sh" vs "sh.exe" part, but what about the
"killed" vs "interrupt" part? any idea why this happens on MS-Windows?
diff --git a/test/lisp/eshell/esh-proc-tests.el b/test/lisp/eshell/esh-proc-tests.el
index a8be0f8..3f67961 100644
--- a/test/lisp/eshell/esh-proc-tests.el
+++ b/test/lisp/eshell/esh-proc-tests.el
@@ -59,7 +59,7 @@ esh-proc-test/kill-pipeline
(eshell-wait-for-subprocess t)
(should (equal (buffer-substring-no-properties
output-start (eshell-end-of-output))
- "killed\n")))))
+ (or "interrupt\n" "killed\n"))))))
(ert-deftest esh-proc-test/kill-pipeline-head ()
"Test that killing the first process in a pipeline doesn't
@@ -88,4 +88,4 @@ esh-proc-test/kill-background-process
(kill-process (caar eshell-process-list))
;; Give `eshell-sentinel' a chance to run.
(sit-for 0.1)
- (eshell-match-result "\\[sh\\] [[:digit:]]+\n")))
+ (eshell-match-result "\\[sh\\(\\.exe\\)?\\] [[:digit:]]+\n")))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Thu, 24 Feb 2022 18:56:02 GMT)
Full text and
rfc822 format available.
Message #19 received at 54136 <at> debbugs.gnu.org (full text, mbox):
On 2/24/2022 3:03 AM, Eli Zaretskii wrote:
>> From: Lars Ingebrigtsen <larsi <at> gnus.org>
>> Date: Thu, 24 Feb 2022 10:35:32 +0100
>> Cc: 54136 <at> debbugs.gnu.org
>>
>> Thanks; pushed to Emacs 29.
>
> The new tests fail on MS-Windows. Does the patch below look right?
Thanks, and sorry for the breakage.
> I'm quite sure about the "sh" vs "sh.exe" part, but what about the
> "killed" vs "interrupt" part? any idea why this happens on MS-Windows?
I think this makes sense. POSIX-style signal handling on MS Windows is
only approximate, so I'm not surprised it produces some surprising
results like that. Maybe it's possible to pass the signal code through
the process exit status more accurately, but that's probably only a
partial solution at best (due to the API differences), and at worst
could break Emacs's subprocess handling for MS Windows in subtle ways.
Another solution would be to replace the call to `eshell-kill-process'
in `esh-proc-test/kill-pipeline' with `eshell-interrupt-process'. Then
the exit status should be "interrupt\n" on all platforms. I've verified
that that works ok on GNU/Linux, but it's possible that it runs into
some other issue on MS Windows.
This is sort of just working around the issue, but I also think there's
an argument that `eshell-interrupt-process' is the more "natural"
function to call, since it corresponds to a user hitting ^C in the shell
(or C-c C-c in Eshell).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Thu, 24 Feb 2022 20:04:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 54136 <at> debbugs.gnu.org (full text, mbox):
> Cc: 54136 <at> debbugs.gnu.org
> From: Jim Porter <jporterbugs <at> gmail.com>
> Date: Thu, 24 Feb 2022 10:55:48 -0800
>
> > I'm quite sure about the "sh" vs "sh.exe" part, but what about the
> > "killed" vs "interrupt" part? any idea why this happens on MS-Windows?
>
> I think this makes sense. POSIX-style signal handling on MS Windows is
> only approximate, so I'm not surprised it produces some surprising
> results like that. Maybe it's possible to pass the signal code through
> the process exit status more accurately, but that's probably only a
> partial solution at best (due to the API differences), and at worst
> could break Emacs's subprocess handling for MS Windows in subtle ways.
>
> Another solution would be to replace the call to `eshell-kill-process'
> in `esh-proc-test/kill-pipeline' with `eshell-interrupt-process'. Then
> the exit status should be "interrupt\n" on all platforms. I've verified
> that that works ok on GNU/Linux, but it's possible that it runs into
> some other issue on MS Windows.
>
> This is sort of just working around the issue, but I also think there's
> an argument that `eshell-interrupt-process' is the more "natural"
> function to call, since it corresponds to a user hitting ^C in the shell
> (or C-c C-c in Eshell).
OK, so I installed my changes.
Thanks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Thu, 24 Feb 2022 20:08:02 GMT)
Full text and
rfc822 format available.
Message #25 received at 54136 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii <eliz <at> gnu.org> writes:
> OK, so I installed my changes.
The test now fails on Debian:
Test esh-proc-test/kill-pipeline condition:
(ert-test-failed
((should
(equal
(buffer-substring-no-properties output-start ...)
(or "interrupt\n" "killed\n")))
:form
(equal "killed\n" "interrupt\n")
:value nil :explanation
(arrays-of-different-length 7 10 "killed\n" "interrupt\n" first-mismatch-at 0)))
FAILED 2/4 esh-proc-test/kill-pipeline (0.109668 sec) at lisp/eshell/esh-proc-tests.el:47
passed 3/4 esh-proc-test/kill-pipeline-head (0.112142 sec)
passed 4/4 esh-proc-test/sigpipe-exits-process (1.010359 sec)
Ran 4 tests, 3 results as expected, 1 unexpected (2022-02-24 21:06:48+0100, 1.446135 sec)
1 unexpected results:
FAILED esh-proc-test/kill-pipeline
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Fri, 25 Feb 2022 01:05:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 54136 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 2/24/2022 12:07 PM, Lars Ingebrigtsen wrote:
> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>> OK, so I installed my changes.
>
> The test now fails on Debian:
>
> Test esh-proc-test/kill-pipeline condition:
> (ert-test-failed
> ((should
> (equal
> (buffer-substring-no-properties output-start ...)
> (or "interrupt\n" "killed\n")))
> :form
> (equal "killed\n" "interrupt\n")
> :value nil :explanation
> (arrays-of-different-length 7 10 "killed\n" "interrupt\n" first-mismatch-at 0)))
> FAILED 2/4 esh-proc-test/kill-pipeline (0.109668 sec) at lisp/eshell/esh-proc-tests.el:47
> passed 3/4 esh-proc-test/kill-pipeline-head (0.112142 sec)
> passed 4/4 esh-proc-test/sigpipe-exits-process (1.010359 sec)
>
> Ran 4 tests, 3 results as expected, 1 unexpected (2022-02-24 21:06:48+0100, 1.446135 sec)
>
> 1 unexpected results:
> FAILED esh-proc-test/kill-pipeline
Here's a patch for that. It works for me on GNU/Linux, and hopefully
it's ok on MS Windows too.
[0001-Fix-Eshell-process-tests-to-hopefully-work-on-all-pl.patch (text/plain, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Fri, 25 Feb 2022 02:20:02 GMT)
Full text and
rfc822 format available.
Message #31 received at 54136 <at> debbugs.gnu.org (full text, mbox):
Jim Porter <jporterbugs <at> gmail.com> writes:
> Here's a patch for that. It works for me on GNU/Linux, and hopefully
> it's ok on MS Windows too.
Thanks; pushed to the trunk.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Fri, 25 Feb 2022 07:10:01 GMT)
Full text and
rfc822 format available.
Message #34 received at 54136 <at> debbugs.gnu.org (full text, mbox):
> Cc: 54136 <at> debbugs.gnu.org
> From: Jim Porter <jporterbugs <at> gmail.com>
> Date: Thu, 24 Feb 2022 17:04:42 -0800
>
> On 2/24/2022 12:07 PM, Lars Ingebrigtsen wrote:
> > Eli Zaretskii <eliz <at> gnu.org> writes:
> >
> >> OK, so I installed my changes.
> >
> > The test now fails on Debian:
> >
> > Test esh-proc-test/kill-pipeline condition:
> > (ert-test-failed
> > ((should
> > (equal
> > (buffer-substring-no-properties output-start ...)
> > (or "interrupt\n" "killed\n")))
> > :form
> > (equal "killed\n" "interrupt\n")
> > :value nil :explanation
> > (arrays-of-different-length 7 10 "killed\n" "interrupt\n" first-mismatch-at 0)))
> > FAILED 2/4 esh-proc-test/kill-pipeline (0.109668 sec) at lisp/eshell/esh-proc-tests.el:47
> > passed 3/4 esh-proc-test/kill-pipeline-head (0.112142 sec)
> > passed 4/4 esh-proc-test/sigpipe-exits-process (1.010359 sec)
> >
> > Ran 4 tests, 3 results as expected, 1 unexpected (2022-02-24 21:06:48+0100, 1.446135 sec)
> >
> > 1 unexpected results:
> > FAILED esh-proc-test/kill-pipeline
>
> Here's a patch for that. It works for me on GNU/Linux, and hopefully
> it's ok on MS Windows too.
Thanks, and sorry for the thinko. (I thought posting the patch would
have that caught, but I guess no one reads my patches seriously.)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#54136
; Package
emacs
.
(Fri, 25 Feb 2022 18:32:01 GMT)
Full text and
rfc822 format available.
Message #37 received at 54136 <at> debbugs.gnu.org (full text, mbox):
On 2/24/2022 11:09 PM, Eli Zaretskii wrote:
>> Here's a patch for that. It works for me on GNU/Linux, and hopefully
>> it's ok on MS Windows too.
>
> Thanks, and sorry for the thinko. (I thought posting the patch would
> have that caught, but I guess no one reads my patches seriously.)
Indeed, sorry about that. I spent an hour reading the Emacs's C sources
and digging through Microsoft docs on subprocesses to try and understand
why the exit message differed, but neglected the obvious step of "read
the actual patch". D'oh.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 26 Mar 2022 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 89 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.