From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ioannis Kappas 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 19:25:31 +0000 Message-ID: References: <83h7mlj75u.fsf@gnu.org> <83eehpj640.fsf@gnu.org> <83pn17j4pw.fsf@gnu.org> <831rdmitlz.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.40.0.2.32\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15871"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46388@debbugs.gnu.org, Paul Eggert To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 11 20:43:36 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 1lAHsG-00041U-7W for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Feb 2021 20:43:36 +0100 Original-Received: from localhost ([::1]:47024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAHsF-0003Rt-A6 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 11 Feb 2021 14:43:35 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAHbH-0002Tt-2y for bug-gnu-emacs@gnu.org; Thu, 11 Feb 2021 14:26:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lAHbG-0005HS-Ks for bug-gnu-emacs@gnu.org; Thu, 11 Feb 2021 14:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lAHbG-0003tb-Fa for bug-gnu-emacs@gnu.org; Thu, 11 Feb 2021 14:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ioannis Kappas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Feb 2021 19:26:02 +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.161307154414949 (code B ref 46388); Thu, 11 Feb 2021 19:26:02 +0000 Original-Received: (at 46388) by debbugs.gnu.org; 11 Feb 2021 19:25:44 +0000 Original-Received: from localhost ([127.0.0.1]:59293 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lAHax-0003t3-QU for submit@debbugs.gnu.org; Thu, 11 Feb 2021 14:25:44 -0500 Original-Received: from mail-wm1-f49.google.com ([209.85.128.49]:52130) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lAHat-0003sn-5F for 46388@debbugs.gnu.org; Thu, 11 Feb 2021 14:25:42 -0500 Original-Received: by mail-wm1-f49.google.com with SMTP id u16so2891483wmq.1 for <46388@debbugs.gnu.org>; Thu, 11 Feb 2021 11:25:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HomaABrx46NaocFe6Tpvz2gUJq0DUsw6l5YP++FSXOg=; b=OBV+A9CR08U1roldGPn0tVZVmq/cG7LiG7C6T0Eld88vhE45kskvo21+7a6qYp8NWe oW6JUgaTkx3ep8uzrLFlp9kcTPc1deLk1QPlDvUJkxpKpGnDYa0ss7aukrC0aPMLrgeo jItSarbeDNBSiVZbGoAkbN/TvA5jHS+xIYdKZlaPSC788U5nv03DpIP8Vv4YlcFJZ6km 1PA43RfiUeiTVRv5N4bIRxIyZuYT3XRgx7DbuWas/46w8GCN8e6jeMkh0I2tAh2gSD+G FKWUEy3IQJCObJ1xUz+fnItz0yrMVX03lFcaNlupl6b28BpnMGreFX0Ipc3jYeYl5oiy kYYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HomaABrx46NaocFe6Tpvz2gUJq0DUsw6l5YP++FSXOg=; b=tjrhDm3fxWuW34+DXKPeOi/hm+LH7B854P3CJY0/p0cS5tRYtpxCId9uAUU00qI24N fY5djoZ4Z87IwR8E17Ltb1RU4iBrY7QJzw2EYyyfQIi0AA29bD4RQIB97+4jobHZPpLi tHMsolj7UuskyuFT1TRAj0imCcvYxos7IKfBzcgVtfuyUHsg2mM9Z2RuBBw+CuYJC4sH ERBFElMg6dqrvQFLzj+DJgiEl/8U+C2DnskncI4KFicgUCnUJbzQQ+c9phy4DlxIrth4 U3o502bKau+oTMyL9iieZoUL08FFSeCAOwW8VX93pInRlJHjqiZBln7IsLPiCsUeN2Cb mfAA== X-Gm-Message-State: AOAM533xqEAn+MPS3tORfXQpZz1yEYTAaSNYm9SFBAYd+WgQbi/Kiv0n pf7FOGx48DgWpKpbVzMa4Cs= X-Google-Smtp-Source: ABdhPJxaFqbQ01k9XwoWNkzk5f7LomgyW/QAxeuRGcbZf6ZfvcxVLM/BgxJLyjVC6H6EHFoauayFtQ== X-Received: by 2002:a1c:2d8a:: with SMTP id t132mr6326795wmt.119.1613071533210; Thu, 11 Feb 2021 11:25:33 -0800 (PST) Original-Received: from 192.168.1.103 ([188.214.14.133]) by smtp.gmail.com with ESMTPSA id f2sm6270690wrt.7.2021.02.11.11.25.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2021 11:25:32 -0800 (PST) In-Reply-To: <831rdmitlz.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.40.0.2.32) 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:199825 Archived-At: > On 11 Feb 2021, at 14:09, Eli Zaretskii wrote: >=20 >> From: Ioannis Kappas >> Date: Thu, 11 Feb 2021 08:10:34 +0000 >> Cc: 46388@debbugs.gnu.org >>=20 >>> My reading of the code is that we already fflush stderr after = emitting >>> a message, so this should already happen. See message_to_stderr. = If >>> that still doesn't help, then there's some buffering in the OS (for >>> example, in the pipe machinery itself), which we cannot control. >>=20 >> the xdisp.c:message_to_stderr() is the first function i studied with >> gdb when I started the investigation. Unless I've missed something, >> it does not seem to lead to calling fflush (under windows at least): >=20 > Then maybe this: >=20 >> /* Return the error output stream. */ >> static FILE * >> errstream (void) >> { >> FILE *err =3D buferr; >> if (!err) >> return stderr; >> fflush_unlocked (stderr); <<<<<<<<<<<<<<<< >> return err; >> } >=20 > should be fixed to fflush 'buferr' instead (or in addition to stderr)? >=20 > Paul, isn't that a bug that we fflush stderr here, and not 'buferr=E2=80= =99? (just a small note, =E2=80=9Cbuffer" is NULL under windows, 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)