unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ioannis Kappas <ioannis.kappas@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 46388@debbugs.gnu.org, Paul Eggert <eggert@cs.ucla.edu>
Subject: bug#46388: 27.1; emacs -batch does not output messages immediately when invoked outside of the command prompt
Date: Fri, 12 Feb 2021 19:59:02 +0000	[thread overview]
Message-ID: <CAMRHuGDyCObLN8=Vqg0FGNzEpcvv48_Tx6-0fFjeKQvTn4hWSQ@mail.gmail.com> (raw)
In-Reply-To: <83a6sagz1n.fsf@gnu.org>

Hi Eli

Just to recap (with a touch of drama this time).

The following command

emacs -Q --batch --eval="(progn (message \"The bomb will explode in 10
seconds, cut the red cable to disarm\") (sit-for 3600))"

will behave differently depending on the architecture/prompt it is invoked from:

When it is invoked from the Linux terminal or from a plain emacs
eshell (i.e. M-x eshell) prompt  or from a windows command prompt =>
message is printed out immediately, user cuts the red cable, bomb
doesn't explode.

When it is invoked from msys64 mintty terminal or from emacs eshell on
windows => no message is printed out (until emacs -batch returns), no
cables cut, bomb explodes after ten seconds.

How do you suggest we flush the message out so that it is always
displayed to the user irrespective of the architecture/prompt it is
ran on? Is there perhaps an elisp function to flush messages out (e.g.
(progn (message "...") (message-flush!) (sit-for ...))) ?

So far we said:
1. We don't want to a solution where the emacs -batch's stderrr is
forced to unbuffered mode (original patch proposal)
2. message_to_stderr() does not directly or indirectly invoke stderr
flush (at least in windows).

Thanks

On Thu, Feb 11, 2021 at 7:55 PM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Ioannis Kappas <ioannis.kappas@gmail.com>
> > Date: Thu, 11 Feb 2021 19:25:31 +0000
> > Cc: Paul Eggert <eggert@cs.ucla.edu>,
> >  46388@debbugs.gnu.org
> >
> > (just a small note, “buffer" is NULL under windows
>
> Which is a Good Thing, since otherwise we'd have stderr always fully
> buffered on Windows (since _IOLBF on Windows is interpreted the same
> as _IOFBF, i.e. fully-buffered).
>
> >, the fn thus returns without flushing anything. Even if buffer was not NULL, the fflush fn would have flushed the content of what ever has been accumulated on the stderr buffer so far, but not the message just  sent to message_to_stderr that we want to print out. Although, there would be this weird effect; message_to_sderr()  does an fwrite of the message followed by an fputc of a newline. This means that if errstream() was to fflush stderr, it would have flushed only the message written by fwrite, and not the newline written by fputc. I think that, if we are indeed considering to explicitly flush the message to stder, the correct place to do it would be directly inside the message_to_stderr(), thanks)
>
> If buferr is NULL, we are using the original stderr, which is supposed
> to be unbuffered.
>
> But I think you again are looking at the wrong side of the pipe: the
> parent Emacs process reads from a pipe, which as its own buffering.
> So whatever we do with Emacs's stderr will only affect subprocesses
> when the child process is also Emacs, and will not have any effect on
> other programs being run as subprocesses.
>
> The correct solution, one that will seamlessly fix all the aspects of
> the buffering, is to add pseudo-console support to Emacs on Windows,
> and use that by default on systems that can support it.





  reply	other threads:[~2021-02-12 19:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-08 21:20 bug#46388: 27.1; emacs -batch does not output messages immediately when invoked outside of the command prompt Ioannis Kappas
2021-02-08 21:42 ` Ioannis Kappas
2021-02-09  5:36   ` Eli Zaretskii
2021-02-09 20:15     ` Ioannis Kappas
2021-02-09 20:52       ` Eli Zaretskii
2021-02-09 21:14         ` Eli Zaretskii
     [not found]           ` <CAMRHuGC_p59uw_hmCL65Z0F1ZdFbVAf9MHcB-sX88bW6jchC-Q@mail.gmail.com>
2021-02-10 12:48             ` Ioannis Kappas
2021-02-10 15:57               ` Eli Zaretskii
2021-02-11  8:10                 ` Ioannis Kappas
2021-02-11 14:09                   ` Eli Zaretskii
2021-02-11 19:25                     ` Ioannis Kappas
2021-02-11 19:55                       ` Eli Zaretskii
2021-02-12 19:59                         ` Ioannis Kappas [this message]
2021-02-12 20:03                           ` Eli Zaretskii
2021-03-06 15:00                             ` Ioannis Kappas
2021-03-08  4:05                               ` Paul Eggert
2021-03-08  7:56                                 ` Ioannis Kappas
2021-03-11 14:27                                 ` Eli Zaretskii
2021-03-11 18:43                                   ` Paul Eggert
2021-02-11 21:15                     ` Paul Eggert
2021-02-09  3:38 ` Eli Zaretskii

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='CAMRHuGDyCObLN8=Vqg0FGNzEpcvv48_Tx6-0fFjeKQvTn4hWSQ@mail.gmail.com' \
    --to=ioannis.kappas@gmail.com \
    --cc=46388@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=eliz@gnu.org \
    /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).