Using this script:

#!/usr/bin/perl use strict; use diagnostics; use warnings; my $pid = fork || exec 'play', '/home/ra/Desktop/trek2.mp3'; print "My PID is *$pid*\n"; sleep 5; kill $pid;

The file starts playing, and I would hope that it stops playing after 5 seconds, but it doesn't. Here's the terminal output before the 5 second cut-off:

ra@eagle ~/Local/Code/amudclient/test/playsound $ ./playsound.pl My PID is *21417* /home/ra/Desktop/trek2.mp3: File Size: 506k Bit Rate: 135k Encoding: MPEG audio Info: 2017-09-26T15:54 Channels: 2 @ 16-bit Track: 309 Samplerate: 44100Hz Album: This Week in Trek Replaygain: off Artist: Michael Gaines and Darrell Skeels Duration: 00:00:30.07 Title: This Week in Trek Episode 309 In:17.6% 00:00:05.29 [00:00:24.77] Out:233k [ =|= ] Cl +ip:0

And the terminal output, once the file stops playing naturally.

ra@eagle ~/Local/Code/amudclient/test/playsound $ ./playsound.pl My PID is *21364* /home/ra/Desktop/trek2.mp3: File Size: 506k Bit Rate: 135k Encoding: MPEG audio Info: 2017-09-26T15:54 Channels: 2 @ 16-bit Track: 309 Samplerate: 44100Hz Album: This Week in Trek Replaygain: off Artist: Michael Gaines and Darrell Skeels Duration: 00:00:30.07 Title: This Week in Trek Episode 309 In:17.0% 00:00:05.11 [00:00:24.96] Out:225k [ -====|====- ] Cl +ip:0 raIn:28In:In:In:29.7%In:3In:3In:In:In:32In:InInIn:46.6% 00In: +47.3% 0In:47InIn:100% 00:00:30.07 [00:00:00.00] Out:1.33M [ ===|== += ] Clip:0 Done.

In reply to Re^4: Killing a child process by Anonymous Monk
in thread Killing a child process by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.