c++ - Qt QProcess startDetached can't end process (bash session) -


i'm trying call shell script qt gui, after running script, bash session stays open when should finish.

having 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 script, expecting command entered, can put command , execute it. problem never finishes until enter command.

i tried modifying s variable this:

qstring s = "./script.sh " + argument + " ;exit"; 

hoping end bash session, nothing happens.

if instead of using function startdetached use start close bash session without ;exit command.

hope knows how solve or workaround!

startdetached() static method; started new process, it's not represented process object.

when wait process finish, wait forever, because process never started.

try like:

process.start("/bin/bash", qstringlist() << "-c" << s); bool finished = process.waitforfinished(-1); 

you might want redirect i/o before start().


Comments