PDA

View Full Version : Ignoring stdout and stder of detached process



Lapsio
30th July 2012, 16:27
Hi. I've got some troubles with debugging my app. I'm running new process with QProcess::startDetached (command), but it gives a lot of logs. I don't need them, so my question is - how can i disable printing stdoutput and stderror of this new process? I've tried:



QProcess newprocess
newprocess.startDetached ("xscreensaver-command -deactivate");
newprocess.CloseReadChannel(newprocess.StandartErr or());
newprocess.CloseReadChannel(newprocess.StandartOut put());


But it doesn't work. xcreensaver prints his warning about running statement.

ChrisW67
31st July 2012, 05:38
QProcess::startDetatched() is static, so the newProcess instance has no relationship to the process you started. So, even if the things you've "tried" would compile (they won't) they would not change the launched process.

Since the command you are running is short lived you can just start it and ignore its output. Try:


QProcess p;
p.start("xscreensaver-command", QStringList() << "-deactivate");