Last active
August 29, 2015 13:57
-
-
Save mezis/9536577 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env ruby | |
# | |
# Thread, fork, and try to trigger deadlocks | |
# | |
def make_noise | |
$stdout.write("\000") | |
end | |
[1,2].each do | |
Thread.new do | |
while true | |
make_noise | |
end | |
end | |
end | |
while true | |
pid = fork { make_noise } | |
Process.waitpid(pid) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will cause deadlocks in the forked processes in MRI 1.9.3, but not in 1.8.7 or 2.0+.
It surfaces with any output file, with or without flushing, and starting from 2 extra threads in the main process (1 extra thread only does not trigger the issue).