Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1347587

[PATCH 3.14 092/130] uml: flush stdout before forking

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 3.14 092/130] uml: flush stdout before forking
Date Wed, 02 Mar 2016 03:00:04 +0100
Message-ID <r84f2-EO-55@gated-at.bofh.it> (permalink)
References <r82dd-7Iy-13@gated-at.bofh.it>
X-Original-To <linux-kernel@vger.kernel.org>
Dkim-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; s=mandrill; d=linuxfoundation.org; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; i=gregkh@linuxfoundation.org; bh=LcjRANJZfzCNDnw/lBpULENOcQ8=; b=aQvfeI3pGAo0WVwbkJEOpuaFzEZ0jYCa4FgJP6Ud8mmMpqKTiz0cht78hdaFzZ0bY9wHytfumWW9 EVoWl4is+xmwq/Ri8TLa4D72HxnJejoMgz6Epa3Zm+r7Pue0GfsjSSNMQieYfDNihRdCL1E/gc1B PbwNdYYLZYsSrak/zaA=
Domainkey-Signature a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=VFqqL5cZglQbMw90S0sUOy3EJusKw9K8Ppr16CIWHwbbUaBZTrZ6pNMdacis1L+ANoG8DW4NF6CW sORdtHmryzcf+VVBLgVWb8WAwKXzGbdfNyf1Ke9zupVCKZ8dGneWpS0+PXQF4oyUtKg+ukfKaBJZ gCutkJs0LNOGRryUijk=;
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; i=@mandrillapp.com; q=dns/txt; s=mandrill; t=1456876408; h=From : Subject : To : Cc : Message-Id : In-Reply-To : References : Date : MIME-Version : Content-Type : Content-Transfer-Encoding : From : Subject : Date : X-Mandrill-User : List-Unsubscribe; bh=dgqweyrY1qhSzr4x155OKKlBEhuhXBqkPFOLV9cxoT0=; b=Sj7WYHOY2nLlWiRzQGuqqFjYwpz24QloMEHh9wD68hfxEUqqYqxdaWAoMbRirwNatgEYmg gIi+n5I0qeK3i1buktdIv/23yNYYCU1mJGkEY6RkCNt3SekNv0AE2s33Org7dGXjcxtLTEAH V0M4HxJy6e2YQXIOyvU+7TSNx3j4Q=
X-Mailer git-send-email 2.7.2
X-Report-Abuse Please forward a copy of this message, including all headers, to abuse@mandrill.com
X-Report-Abuse You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.22ce8ff8aff34de4ae30fea8b6e9230b
X-Mandrill-User md_30481620
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 53
Organization linux.* mail to news gateway
X-Original-Cc Greg Kroah-Hartman <gregkh@linuxfoundation.org>, <stable@vger.kernel.org>, Vegard Nossum <vegard.nossum@oracle.com>, Richard Weinberger <richard@nod.at>
X-Original-Date Tue, 01 Mar 2016 23:53:28 +0000
X-Original-Message-ID <20160301234503.089606516@linuxfoundation.org>
X-Original-References <20160301234459.768886030@linuxfoundation.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1347587

Show key headers only | View raw


3.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Vegard Nossum <vegard.nossum@oracle.com>

commit 0754fb298f2f2719f0393491d010d46cfb25d043 upstream.

I was seeing some really weird behaviour where piping UML's output
somewhere would cause output to get duplicated:

  $ ./vmlinux | head -n 40
  Checking that ptrace can change system call numbers...Core dump limits :
          soft - 0
          hard - NONE
  OK
  Checking syscall emulation patch for ptrace...Core dump limits :
          soft - 0
          hard - NONE
  OK
  Checking advanced syscall emulation patch for ptrace...Core dump limits :
          soft - 0
          hard - NONE
  OK
  Core dump limits :
          soft - 0
          hard - NONE

This is because these tests do a fork() which duplicates the non-empty
stdout buffer, then glibc flushes the duplicated buffer as each child
exits.

A simple workaround is to flush before forking.

Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/um/os-Linux/start_up.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -95,6 +95,8 @@ static int start_ptraced_child(void)
 {
 	int pid, n, status;
 
+	fflush(stdout);
+
 	pid = fork();
 	if (pid == 0)
 		ptrace_child();

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 3.14 092/130] uml: flush stdout before forking Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-03-02 03:00 +0100

csiph-web