0

I have a C++/Qt5 program that sets the priority of the process using setpriority(). That process launches several executable programs using QProcess.

Will the programs launched by QProcess run at the NEW priority of the main process? Or does QProcess set their priority to 0?

Box Box Box Box
  • 5,094
  • 10
  • 49
  • 67
TSG
  • 4,242
  • 9
  • 61
  • 121

1 Answers1

0

Are you talking about QProcesses or QThreads? QProcess doesn't have setPriority, but QThread::setPriority does. This affects pthread scheduling policy, which is by default inherited to child threads.

As for QProcess, at least in *nix it's a regular fork(), which preserves it's niceness value as it was during invocation time. So if you renice the main process, this value is passed to child processes.

Tatu Lahtela
  • 4,514
  • 30
  • 29
  • I am setting the priority of the main process using setprocess (from . I then use QProcess to start another process. This is running under linux. Strangely, when I set the main process to priority -3, the QProcesses started subsequently are at priority 0. I assume it work be a FORK (inherit priority) but it doesn't seem to be, which is strange. – TSG Feb 17 '16 at 19:48
  • Perhaps you don't have privileges to raise priority below 0? This would be the default. Check the return value of setprocess. – Tatu Lahtela Feb 18 '16 at 10:24
  • I can change the priority of the main process to -3 (it's running as root), so that's not the problem. I just can't figure out why launched QProcesses run with priority of 0. They should run with prio -3 (assuming they just fork & span from the main process) – TSG Feb 18 '16 at 14:54