From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Daniele Nicolodi Newsgroups: gmane.emacs.devel Subject: Re: `message' not outputting the newline "atomically" Date: Mon, 24 Jun 2019 14:03:43 -0600 Message-ID: <07619925-e367-fb88-2dd8-27addb2e9052@grinta.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="230696"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 24 22:08:09 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hfVG3-000xqg-IQ for ged-emacs-devel@m.gmane.org; Mon, 24 Jun 2019 22:08:07 +0200 Original-Received: from localhost ([::1]:54376 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfVG2-0000oh-3H for ged-emacs-devel@m.gmane.org; Mon, 24 Jun 2019 16:08:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56201) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hfVC1-0006hf-DY for emacs-devel@gnu.org; Mon, 24 Jun 2019 16:03:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hfVC0-0005AH-Ay for emacs-devel@gnu.org; Mon, 24 Jun 2019 16:03:57 -0400 Original-Received: from zed.grinta.net ([109.74.203.128]:56618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hfVBz-00058V-OE for emacs-devel@gnu.org; Mon, 24 Jun 2019 16:03:56 -0400 Original-Received: from 688dnmac.campus.nist.gov (unknown [132.163.81.39]) (Authenticated sender: daniele) by zed.grinta.net (Postfix) with ESMTPSA id 16A07E0B62 for ; Mon, 24 Jun 2019 20:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=grinta.net; s=mail; t=1561406631; bh=OFtLOVYT7Nsz0WNdxfdl1lYyIhcWc8gTvZzYY+GvnIE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=NV9d2mujEuXxQhmIeYeoX8zW6twqN6oMTPuxxxvoZmuc0NgCqRiHvL+8EEQfDm0Jh wvd3Y45bFPGiJWWNiJUMKJaNF8DQqRSIuULA6G8tD22fY3GN+pkjSJFHxoImd/dYiX zD3GAJfK9q7q0vPO997daOfVjgZWhkMmXflFODNM= In-Reply-To: Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 109.74.203.128 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:238118 Archived-At: On 24-06-2019 13:48, Lars Ingebrigtsen wrote: > So... does this look OK? > > diff --git a/src/xdisp.c b/src/xdisp.c > index 5d70440f1c..0b45ca9e02 100644 > --- a/src/xdisp.c > +++ b/src/xdisp.c > @@ -10705,10 +10705,22 @@ message_to_stderr (Lisp_Object m) > else > s = m; > > - fwrite (SDATA (s), SBYTES (s), 1, stderr); > + /* We want to write this out with a single fwrite call so that > + output doesn't interleave with other processes writing to > + stderr at the same time. */ > + { > + int length = SBYTES (s); > + char *string = xmalloc (length + 1); > + > + memcpy (string, SSDATA (s), length); > + *(string + length) = '\n'; Isn't this more naturally spelled as below? string[length] = '\n'; > + fwrite (string, length + 1, 1, stderr); > + xfree (string); > + } > } > - if (!cursor_in_echo_area) > + else if (!cursor_in_echo_area) > fputc ('\n', stderr); > + > fflush (stderr); I think the fflush() here can be dropped, stderr is not buffered. > } Cheers, Dan