My script uses the SoX package to play a (long) sound file.
exec 'play "/home/myname/soundfile.wav" &';I need to be able to stop the sound before reaching the end of the sound file. The SoX documentation says:
...it can be terminated earlier by sending an interrupt signal to the process (usually by pressing the keyboard interrupt key which is normally Ctrl-C)...I tried this code to generate a child process, play the sound in that process, and kill the child process after a few seconds:
my $pid = fork || exec 'play "/home/myname/soundfile.wav" &'; sleep 5; kill $pid;
It doesn't work, of course. What am I doing wrong?
In reply to Killing a child process by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |