Reputation: 739
I would like know if it's possible to create a QProcess
and initialize it to a process which is already running?
My application starts an other application. So if my application is abnormally closed, when it will be restarted, I would like attach the other application.
Upvotes: 5
Views: 3069
Reputation: 98425
Unfortunately, due to the internal architecture of QProcess
, there's no support for this. You'd need to copy-paste a bunch of QProcess
code to a new class and add the missing functionality yourself.
There's an easier way, though: create a process wrapper that exposes a QProcess
via QLocalSocket
. The wrapper is simple and shouldn't be crashing. It can self-terminate when the process itself terminates, to prevent dangling wrappers from hanging around. When your application crashes or is terminated, the new instance can try to attach to the local socket if a wrapper exists. If it doesn't exist, then it will spawn a new wrapper.
Upvotes: 1