Skip to content

Instantly share code, notes, and snippets.

@jpcamara
Last active December 24, 2023 11:46
Show Gist options
  • Save jpcamara/e54d6dd5e2c779e20c94b9c3e5cb14c6 to your computer and use it in GitHub Desktop.
Save jpcamara/e54d6dd5e2c779e20c94b9c3e5cb14c6 to your computer and use it in GitHub Desktop.
# hangs, same as MN threads
# RUBY_MN_THREADS=1 make test-all TESTS="--name=TestIO#test_open_fifo_does_not_block_other_threads"
require "tempfile"
require "async"
def mkcdtmpdir
Dir.mktmpdir {|d|
Dir.chdir(d) {
yield
}
}
end
mkcdtmpdir {
File.mkfifo("fifo")
Async do |task|
t1 = task.async {
open("fifo", "r") {|r|
r.read
}
}
t2 = task.async {
open("fifo", "w") {|w|
w.write "foo"
}
}
# Hangs indefinitely
puts t1.wait
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment