Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
worker_thread = Thread.new do
start_working_forever unless worker_thread[:stop]
end
default = trap(:INT) do
timeout = 30
slayer = Thread.new do
sleep timeout
worker_thread.terminate if worker_thread.alive?
end
trap(:INT, default)
worker_thread[:stop] = true
worker_thread.join
exit
end
worker_thread.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment