How can I suspend and resume a subprocess that I started as a QProcess in Qt? Is there a Qt function for that, or if not, a platform-specific one that would work on Linux?
Asked
Active
Viewed 1,367 times
4
-
Stopping the espeak process may or may not immediately stop sound coming out of your speakers. – n. m. could be an AI Jul 17 '16 at 08:53
-
I tested it on my computer (Ubuntu linux), and sound stops immediately. Why would it not stop immediately? – sashoalm Jul 17 '16 at 09:32
-
It depends on how espeak is implemented. If it synthesizes a large chunk of text at a time, and sends it to underlying hardware (or to another process, e.g. a sound daemon), then stopping the process will not have effect on the chunk already sent and it would play to the end. – n. m. could be an AI Jul 17 '16 at 09:42
-
Haven't you found any solution also for Windows? – HiFile.app - best file manager Feb 07 '20 at 10:46
1 Answers
4
Since I'm on linux, I used the kill() function.
#include <signal.h>
...
kill(process->pid(), SIGSTOP); // suspend
kill(process->pid(), SIGCONT); // resume
-
1Works perfectly... I'm using C++ Qt QProcess and this works like a charm in pausing and resuming a process... – Maxx Sep 04 '16 at 15:26