Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Killing a child process
by ikegami (Patriarch) on Oct 03, 2017 at 07:36 UTC | |
by Anonymous Monk on Oct 03, 2017 at 07:47 UTC | |
by ikegami (Patriarch) on Oct 03, 2017 at 07:51 UTC | |
by Anonymous Monk on Oct 03, 2017 at 08:11 UTC | |
by hippo (Archbishop) on Oct 03, 2017 at 08:20 UTC | |
|
Re: Killing a child process
by haukex (Archbishop) on Oct 03, 2017 at 08:09 UTC | |
by Anonymous Monk on Oct 03, 2017 at 08:13 UTC | |
by haukex (Archbishop) on Oct 03, 2017 at 08:30 UTC | |
by Anonymous Monk on Oct 04, 2017 at 08:56 UTC | |
by haukex (Archbishop) on Oct 04, 2017 at 10:50 UTC | |
by Anonymous Monk on Oct 04, 2017 at 14:01 UTC | |
by haukex (Archbishop) on Oct 04, 2017 at 15:25 UTC | |
|
Re: Killing a child process
by Anonymous Monk on Oct 03, 2017 at 08:34 UTC | |
by ikegami (Patriarch) on Oct 03, 2017 at 15:37 UTC |