bashpipekillfestival

How can I kill a Festival speech command?


Let's say I run the following command:

cat /var/log/dmesg | festival --tts

This might return the message [1] 4726, indicating a process ID associated with this operation. When I run kill 4726 or killall festival or killall cat or killall aplay, the speech does not stop (or, at least, it continues on for quite some time before stopping). If I run the command above, how can I kill what it starts doing?


Solution

  • Kill sends a SIGTERM to the program. SIGTERM tells the program to stop, allowing it to shut down gracefully. The program is unallocating memory, closing connections, flushing to disk, removing temp files, etc. So SIGTERM may not be immediate or quick.

    Kill -9, sends a SIGSTOP or SIGKILL, which is only seen by the kernel. The kernel will terminate the process. While this is faster, it does not allow for a graceful exit.

    I am not familiar with festival, so if you are worried that these commands are forking off processes and you want to stop all the children, you can brute force the issue by spawning them all out of a bash shell. When you kill the parent bash shell, it will kill all of the processes owned by it.

    bash -c "cat /var/log/dmesg | festival --tts" &
    

    You will get bash the pid for the bash shell, which you can kill and clean up all sub-procs.