Subject: bug#55599: save-buffers-kill-emacs doesn't give a visible prompt when called from command line

From: Peter Ludemann <[email-masked]>
Date: Wed, 1 Jun 2022 13:04:42 -0700

On Wed, 1 Jun 2022 at 12:52, Eli Zaretskii <[email-masked]> wrote:

> > From: Peter Ludemann <[email-masked]>
> > Date: Wed, 1 Jun 2022 10:54:02 -0700
> > Cc: Michael Albinus <[email-masked]>, [email-masked]
> >
> > I start the emacs daemon from a terminal by:
> >     emacs --daemon
> >
> > During startup, there might be some prompts (e.g., I get a pagination
> prompt from parsing a tar file, when
> > emacs is loading my last session's files), and I can deal with them at
> the terminal.
> >
> > When I shutdown the emacs daemon, I would like to also do this at the
> terminal:
> >     emacsclient -e '(save-buffers-kill-emacs)'
> > but that doesn't work if there are any prompts (e.g., saving a file or
> killing a shell process).
> > A work-around is to do:
> >     emacsclient -c -e '(save-buffers-kill-emacs)'
> > and that lets me see the prompts in the minibuffer.
> >
> > However, it seems that "emacsclient -e" has access to the terminal's
> stderr.
> > Evidence: I get an error message at the terminal (not in a minibuffer)
> if I do something with an error, such as
> >     emacsclient -e '(man fprintf)'
> >
> > If stderr is being passed in to the evaluation code in daemon mode, then
> it would be nice to also have stdin
> > passed in, which would allow interaction at the terminal.
>
> stderr is not passed.  What happens is that any messages sent by the
> server are echoed by the client on its own stderr.
>
> However, the reverse direction is not supported.  For it to be
> supported, we need a way to tell the server to wait for the client to
> return the user's response.  Such a feature doesn't exist, AFAIK, so
> to support it we need to extend the client-server protocol.
>

That sounds like a lot of work for a very small pay-off (at least, in the
scenario I've given), especially as there's an easy work-around.
Feel free to close this bug/feature-request as "wontfix". ;)

And, again, thank-you for your prompt and very helpful responses (and your
patience with someone who knows very little about the internals of emacs)