lib/mikeplayer/play_thread.rb in mikeplayer-1.0.8 vs lib/mikeplayer/play_thread.rb in mikeplayer-1.1.0
- old
+ new
@@ -36,14 +36,24 @@
kill('INT')
@elapsed += Time.now.to_i - @start_t
@start_t = 0
- sleep 0.2
+ 10.times do
+ break unless alive?
+ sleep 0.1
+ end
+
kill('KILL')
+ 10.times do
+ break unless alive?
+
+ sleep 0.1
+ end
+
@paused = true
end
def kill(signal)
Process.kill(signal, @pid) if alive?
@@ -101,10 +111,14 @@
stdin, stdother, thread_info = Open3.popen2e(*args)
@pid = thread_info.pid
- sleep 0.2
+ 10.times do
+ break if alive?
+
+ sleep 0.2
+ end
raise "Failed to play #{stdother.read}" unless alive?
stdin.close
stdother.close