Actions
Bug #17801
closedrepeated read from PTY blocks all Fibers
Description
Ruby version:
ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [x86_64-linux]
used Scheduler:
https://github.com/ruby/ruby/blob/master/test/fiber/scheduler.rb
Example Code which should work:
require 'pty'
require "./scheduler.rb"
line_event = TracePoint.new(:line) do |t|
p [t.lineno, t.method_id, t.path]
end
Fiber.set_scheduler(Scheduler.new)
master, slave = PTY.open
read, write = IO.pipe
pid = spawn("bash", :in=>read, :out=>slave)
read.close # we dont need the read
slave.close # or the slave
line_event.enable do
Fiber.schedule do
loop do
puts "date"
write.puts "date"
sleep 1
end
end
Fiber.schedule do
loop do
puts master.gets.chomp
puts master.gets.chomp # this line blocks all fibers, why ?
puts "test"
sleep 1
end
end
#write.close
end
Actions
Like0
Like0Like0Like0Like0Like0Like0