[Qt-interest] Can't kill a process with QProcess::kill()

Konrad Rosenbaum konrad at silmor.de
Fri Mar 18 12:52:31 CET 2011


On Fri, March 18, 2011 11:42, Florian S. wrote:
> i try to kill an asynchronously started QProcess (it's a shellscript which
> starts aplay) with
> p->kill(). The sound played by aplay continues, so the process is still
> running.

Because you are only killing the script. Its child process (aplay)
continues to run.

> However, when
> executing this script in a terminal, it can be killed by either SIGKILL
> (kill -9) or SIGINT (^C in
> the terminal).

Because ^C is handed to aplay and the script just stops because its child
failed.

Instead of calling:
#!/bin/sh
aplay .... hallo.wav

Do this instead:
#!/bin/sh
exec aplay .... hallo.wav

This way the shell process is replaced with aplay and you kill aplay
directly.

If you do not do anything fancy in the script, you could also call aplay
from QProcess instead of the script.

In both cases kill() should work. (If not: file a bug report.)


    Konrad




More information about the Qt-interest-old mailing list