[libcamera-devel] [PATCH 1/3] test: process: Fix forking race

Kieran Bingham kieran.bingham at ideasonboard.com
Tue Sep 10 11:04:16 CEST 2019


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 <kieran.bingham at ideasonboard.com>
---
 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<std::string> 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())
-- 
2.20.1



More information about the libcamera-devel mailing list