From patchwork Tue Sep 10 09:04:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1955 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0C8D560BCF for ; Tue, 10 Sep 2019 11:04:26 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8CBEB54A; Tue, 10 Sep 2019 11:04:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1568106265; bh=2x7rlLvn5jUG9FQq4tmlXuHgNXRG2mXOyVonii+cnu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jHCzExoUMR+DBHv1UoHTq8U2Fy4iyAkSxo+VDhKqGXPJ5xN/krJEq1DOrm2PvRT+3 iaYLH5fc3tkGIrAAO1qp5RghPJxYsmJEk3Nw+hYPxG394/X7tztWHN3qtfq3h7+Sq0 d8Tefi+DBhS11hDZCxdYaQWHH2BhsFGlhTPq3AAE= From: Kieran Bingham To: LibCamera Devel Date: Tue, 10 Sep 2019 10:04:16 +0100 Message-Id: <20190910090418.30502-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> References: <20190910090418.30502-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] test: process: Fix forking race X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Sep 2019 09:04:26 -0000 The procFinished event handler is registered after the process is started, leading to the opportunity of a missed race. Register the handler before the process is launched. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Laurent Pinchart --- test/process/process_test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/process/process_test.cpp b/test/process/process_test.cpp index d264555e545f..701f156b5053 100644 --- a/test/process/process_test.cpp +++ b/test/process/process_test.cpp @@ -47,12 +47,13 @@ protected: int exitCode = 42; vector args; args.push_back(to_string(exitCode)); + proc_.finished.connect(this, &ProcessTest::procFinished); + int ret = proc_.start("/proc/self/exe", args); if (ret) { cerr << "failed to start process" << endl; return TestFail; } - proc_.finished.connect(this, &ProcessTest::procFinished); timeout.start(100); while (timeout.isRunning())