I'm trying to call a shell script from a Qt GUI, but after running the script, the bash session stays open when it should finish.
Having this code:
QString s = "./script.sh " + argument;
qint64 *pid = NULL;
QProcess process;
process.startDetached("/bin/bash", QStringList() << "-c" << s, NULL, pid);
bool finished = process.waitForFinished(-1);
std::cout << "ended";
So after running the script, it is expecting a command to be entered, I can put any command and it will execute it. The problem is that it never finishes until I enter a command.
I also tried modifying the s
variable like this:
QString s = "./script.sh " + argument + " ;exit";
hoping that it would end up the bash session, but nothing happens.
If instead of using the function startDetached
I use start
it does close the bash session without the ;exit
command.
Hope someone knows how to solve it or a workaround!