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#46388: 27.1; emacs -batch does not output messages immediately when invoked outside of the command prompt Date: Thu, 11 Feb 2021 21:55:00 +0200 Message-ID: <83a6sagz1n.fsf@gnu.org> References: <83h7mlj75u.fsf@gnu.org> <83eehpj640.fsf@gnu.org> <83pn17j4pw.fsf@gnu.org> <831rdmitlz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6446"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46388@debbugs.gnu.org, eggert@cs.ucla.edu To: Ioannis Kappas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 11 21:07:24 2021 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 1lAIFI-0001af-KB for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Feb 2021 21:07:24 +0100 Original-Received: from localhost ([::1]:59992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAIFG-0006hZ-JH for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Feb 2021 15:07:23 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAI4H-0005lV-TI for bug-gnu-emacs@gnu.org; Thu, 11 Feb 2021 14:56:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47796) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAI4H-0001G0-L1 for bug-gnu-emacs@gnu.org; Thu, 11 Feb 2021 14:56:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lAI4H-0004dj-Iu for bug-gnu-emacs@gnu.org; Thu, 11 Feb 2021 14:56:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Feb 2021 19:56:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46388 X-GNU-PR-Package: emacs Original-Received: via spool by 46388-submit@debbugs.gnu.org id=B46388.161307330717768 (code B ref 46388); Thu, 11 Feb 2021 19:56:01 +0000 Original-Received: (at 46388) by debbugs.gnu.org; 11 Feb 2021 19:55:07 +0000 Original-Received: from localhost ([127.0.0.1]:59342 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lAI3P-0004cW-4e for submit@debbugs.gnu.org; Thu, 11 Feb 2021 14:55:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lAI3N-0004bw-9v for 46388@debbugs.gnu.org; Thu, 11 Feb 2021 14:55:06 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:49506) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAI3H-00016r-GW; Thu, 11 Feb 2021 14:54:59 -0500 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:3609 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1lAI3F-00026L-8P; Thu, 11 Feb 2021 14:54:58 -0500 In-Reply-To: (message from Ioannis Kappas on Thu, 11 Feb 2021 19:25:31 +0000) 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:199827 Archived-At: > From: Ioannis Kappas > Date: Thu, 11 Feb 2021 19:25:31 +0000 > Cc: Paul Eggert , > 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.