From patchwork Sat Sep 5 23:57:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timothy Baldwin X-Patchwork-Id: 514867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 911EE1401DE for ; Sun, 6 Sep 2015 10:02:56 +1000 (AEST) Received: from localhost ([::1]:43567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYNQ6-0002vR-Em for incoming@patchwork.ozlabs.org; Sat, 05 Sep 2015 20:02:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYNLi-00034O-9X for qemu-devel@nongnu.org; Sat, 05 Sep 2015 19:58:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZYNLf-0005v2-57 for qemu-devel@nongnu.org; Sat, 05 Sep 2015 19:58:21 -0400 Received: from avasout06.plus.net ([212.159.14.18]:39202) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZYNLf-0005si-0U for qemu-devel@nongnu.org; Sat, 05 Sep 2015 19:58:19 -0400 Received: from bfg ([87.114.133.92]) by avasout06 with smtp id DbyH1r00C1zmLPr01byJem; Sun, 06 Sep 2015 00:58:18 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.1 cv=E4sw3vpl c=1 sm=1 tr=0 a=wMIFfKY+zwUDgD4aAwecrg==:117 a=wMIFfKY+zwUDgD4aAwecrg==:17 a=0Bzu9jTXAAAA:8 a=FJhpQO9QAAAA:8 a=h_6DSLV0AAAA:8 a=ff-B7xzCdYMA:10 a=TD4pEmZBY6rF_W6A2yoA:9 Received: from tim by bfg with local (Exim 4.84) (envelope-from ) id 1ZYNLc-0008WB-S1; Sun, 06 Sep 2015 00:58:16 +0100 From: Timothy E Baldwin To: qemu-devel@nongnu.org Date: Sun, 6 Sep 2015 00:57:13 +0100 Message-Id: <1441497448-32489-20-git-send-email-T.E.Baldwin99@members.leeds.ac.uk> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441497448-32489-1-git-send-email-T.E.Baldwin99@members.leeds.ac.uk> References: <1441497448-32489-1-git-send-email-T.E.Baldwin99@members.leeds.ac.uk> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 212.159.14.18 Cc: riku.voipio@iki.fi, Timothy E Baldwin Subject: [Qemu-devel] [PATCH 19/34] linux-user: Restart fork() if signals pending X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If there is a signal pending during fork() the signal handler will erroneously be called in both the parent and child, so handle any pending signals first. Signed-off-by: Timothy Edward Baldwin --- linux-user/syscall.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 682090d..1ce381e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4731,6 +4731,11 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, if ((flags & ~(CSIGNAL | CLONE_NPTL_FLAGS2)) != 0) { return -TARGET_EINVAL; } + + if (block_signals()) { + return -TARGET_ERESTARTSYS; + } + fork_start(); ret = fork(); if (ret == 0) {