test: process: Connect signal before launching process
The procFinished event handler is registered after the process is started. This doesn't actually create any race, as the finished signal is emitted after a SIGCHLD is caught and handled through the ProcessManager and processed by the event loop. However, to follow the best practice that resources should be acquired before performing an action, connect the finished signal before starting the process. Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
5d05418d9b
commit
ee35abb7c7
1 changed files with 2 additions and 1 deletions
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue