You are using QProcess::execute() , which is a static function. Quoting Qt Documentation : "Runs a program command in a new process, waits for it to complete."
So what could happen in your code:
QProcess process(); process.execute("ls"); // Start "ls" and wait for it to finish // "ls" has finished bool finished = process.waitForFinished(-1); // Wait for the process to finish, but there is no process and you could get locked here forever...
There are two ways to fix your code:
QProcess process(); process.start("ls"); // Start "ls" and returns bool finished = process.waitForFinished(-1); qDebug() << "End : " << finished << " Output : " << process.errorString();
or
QProcess::execute("ls");
Benjamin t
source share