Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755881AbcCBBGI (ORCPT ); Tue, 1 Mar 2016 20:06:08 -0500 Received: from mail333.us4.mandrillapp.com ([205.201.137.77]:48096 "EHLO mail333.us4.mandrillapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755750AbcCAX4B (ORCPT ); Tue, 1 Mar 2016 18:56:01 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=qI3vH3qIVK1ZwtYny/DDALjEQHDnqGQ4Sgoz4MyNktUlqXZgLbQpdDky/Zu3FCNTCuozSVQOT6If 3bCtIpZoqibQDAxs35dccxzPAhkJCM6e/GPMvda6ocKTwlegQIMyNvZ93L4r8Cv1FAo9gM0qcr0N 5FTnmQuOqgv7Lbw4Pns=; From: Greg Kroah-Hartman Subject: [PATCH 4.4 101/342] uml: flush stdout before forking X-Mailer: git-send-email 2.7.2 To: Cc: Greg Kroah-Hartman , , Vegard Nossum , Richard Weinberger Message-Id: <20160301234531.240099891@linuxfoundation.org> In-Reply-To: <20160301234527.990448862@linuxfoundation.org> References: <20160301234527.990448862@linuxfoundation.org> 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.d2382d98a29d480194f11bb9da3d3c6e X-Mandrill-User: md_30481620 Date: Tue, 01 Mar 2016 23:54:16 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1433 Lines: 53 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vegard Nossum 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 Signed-off-by: Richard Weinberger Signed-off-by: Greg Kroah-Hartman --- 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 @@ -94,6 +94,8 @@ static int start_ptraced_child(void) { int pid, n, status; + fflush(stdout); + pid = fork(); if (pid == 0) ptrace_child();