Created
March 6, 2015 01:56
-
-
Save bpot/db82b1eb2700e9287227 to your computer and use it in GitHub Desktop.
Freezing MRI with FFI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module Block | |
extend FFI::Library | |
ffi_lib FFI::Library::LIBC | |
attach_function :sleep, [:uint], :void | |
end | |
Thread.new { | |
sleep 10 | |
puts "About to block the process" | |
Block.sleep 3600 | |
} | |
loop do | |
puts "#{Time.now}: We are still alive!" | |
sleep 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2015-03-05 17:54:27 -0800: We are still alive! | |
2015-03-05 17:54:28 -0800: We are still alive! | |
2015-03-05 17:54:29 -0800: We are still alive! | |
2015-03-05 17:54:30 -0800: We are still alive! | |
2015-03-05 17:54:31 -0800: We are still alive! | |
2015-03-05 17:54:32 -0800: We are still alive! | |
2015-03-05 17:54:33 -0800: We are still alive! | |
2015-03-05 17:54:34 -0800: We are still alive! | |
2015-03-05 17:54:35 -0800: We are still alive! | |
2015-03-05 17:54:36 -0800: We are still alive! | |
About to block the process |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment