Hi,

On Sat, Nov 19, 2016 at 08:33:05PM -0800, Micky Scandal wrote:
> got Thread.kill to work (is fork something different?

#fork creates a new process. Thread.new creates a new thread within a
process. These are completely different beasts. A thread is still part
of your program, #fork creates a new program (by copying your old one
first). #exec replaces the running program (if used inside a #fork, the
copy) with a completely different program you start with #exec. As a
result, you have two (semi-)independant programs afterwards (for true
independence more is involved, but that's not the point here).

> but mpg123 still continued to run after the script. so short answer,
> killing the thread won't stop the song, so....what will!?

Since you want to run an external program, `mp123', placing that in a
separate thread duplicates parallism. Use fork/exec or even betters its
alias #spawn, record the PID, and when your program exits, shoot down
the process playing the audio. Simple example:

    pid = spawn("mp123 -q floyd_wish.mp3") # Same as fork/exec
    # ...Do your other stuff...
    Process.kill("TERM", pid)
    Process.wait

And please stop top-posting and fullquoting. Instead quote only those
parts you actually reply to. There is no need to have three and more
copies of your messages on this list (look at how I quoted in this
message).

Greetings
Marvin

-- 
Blog: http://www.guelkerdev.de
PGP/GPG ID: F1D8799FBCC8BC4F

Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>