3

Is there some way to read the PID of a process started with QProcess.start(...)? QProcess::pid() returns sip.voidptr and there's not much I can do with it (or I don't know how).

I want to have the PID to have the possibility to make the window active later on.

Daniel Hedberg
  • 5,677
  • 4
  • 36
  • 61
middleofdreams
  • 353
  • 3
  • 13

3 Answers3

2

Try QProcess.startDetached since it spawns a standalone process, removing the possibility of sharing PID with its parent.

This might provide some you further insight.

Bleeding Fingers
  • 6,993
  • 7
  • 46
  • 74
  • I know that startDetached returns pid of new process... but is there possibility of catch finished() signal? Also... it is a separate process anyway... so I don't get why it is not simplified? – middleofdreams Apr 17 '13 at 06:09
0

Try:

proc = QtCore.QProcess().start(cmdOrWhaterver)
pid = int(proc.pid())

Not sure if this helps you or not but you can also try proc.setObjectName() which has worked for me when referencing a process after it has run for a bit.

that's for python anyway

Spencer
  • 1,931
  • 1
  • 21
  • 44
0

pid() function is provided to keep old source code working. Use processId() instead. Returns the native process identifier for the running process, if available. If no process is currently running, 0 is returned. Note: Unlike processId(), pid() returns an integer on Unix and a pointer on Windows.

Avo Asatryan
  • 404
  • 8
  • 21