unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#56002: src/process.c; make-process fails to clean up stderr process on early exit
@ 2022-06-15 22:38 Tom Gillespie
  2022-06-16  2:28 ` bug#56002: update with an additional example Tom Gillespie
  2022-06-16  5:13 ` bug#56002: src/process.c; make-process fails to clean up stderr process on early exit Eli Zaretskii
  0 siblings, 2 replies; 14+ messages in thread
From: Tom Gillespie @ 2022-06-15 22:38 UTC (permalink / raw)
  To: 56002

If the primary subprocess created by make-process fails early then the
stderr process is not cleaned up and running kill-buffer on any stderr
buffer attached to the stderr process will prompt the user.

Two early exits that can cause the issue are

1. in make-process if the command is not found
report_file_error ("Searching for program", program);

2. in create_process if vfork fails
report_file_errno (CHILD_SETUP_ERROR_DESC, Qnil, vfork_errno);

I'm sure there are other failure modes that would trigger the issue.

I know of at least two ways to trigger the behavior that correspond to
those two lines. One is to provide a :command that does not exist, the
other is to call an executable file with a format that Emacs does not
understand (e.g. a valid sh file that is missing a shebang line).

The following example shows the behavior for a non-existent command on
master at 556c304007fbea1a552c65529fa86c0a5637b27b. When running it
the program will stop at a prompt to kill the " rc stderr" buffer.
#+begin_src bash
read -r -d '' example <<'EOF'
(let ((stderr-buffer (generate-new-buffer " rc stderr")))
  (unwind-protect
      (let ((process
             (make-process
              :name "process that never actually starts"
              :stderr stderr-buffer
              :command '("i_fail_before_there_can_be_a_return_code")))))
    (kill-buffer stderr-buffer)))
EOF
src/emacs -Q -batch -eval "${example}"
#+end_src

One potential fix for the issue would be to decouple :noquery for the
primary process from the stderr process and make the stderr process
query_on_exit always false. The user has no knowledge that the stderr
process exists and also has no way to reference it from their code. If
they want :noquery nil behavior an advanced user could always
construct the stderr process themselves.

If that is done then it seems that the stderr process will
automatically clean itself up once the stderr buffer is killed. This
seems easier than trying to catch all early exit cases that would
leave the stderr process alive during an early exit.





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-08-11  6:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15 22:38 bug#56002: src/process.c; make-process fails to clean up stderr process on early exit Tom Gillespie
2022-06-16  2:28 ` bug#56002: update with an additional example Tom Gillespie
2022-06-16  5:13 ` bug#56002: src/process.c; make-process fails to clean up stderr process on early exit Eli Zaretskii
2022-06-16  6:11   ` Tom Gillespie
2022-06-29 21:17     ` Tom Gillespie
2022-08-07 23:48       ` Tom Gillespie
2022-08-08 11:36         ` Lars Ingebrigtsen
2022-08-08 11:57           ` Eli Zaretskii
2022-08-08 18:54             ` Tom Gillespie
2022-08-09 11:43               ` Eli Zaretskii
2022-08-09 18:59                 ` Tom Gillespie
2022-08-10 18:06                   ` Eli Zaretskii
2022-08-11  2:33                     ` Tom Gillespie
2022-08-11  6:30                       ` Eli Zaretskii

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).