Project

General

Profile

Actions

Bug #19039

open

Closing an IO being select'ed in another thread does not resume the thread

Added by mame (Yusuke Endoh) about 2 years ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
[ruby-core:110194]

Description

Is this intentional?

r1, w1 = IO.pipe
r2, w2 = IO.pipe

Thread.new do
  select([r1, r2])
  p :ok
end

sleep 1

p r1.close
# expected: closing r1 resumes select([r1, r2]) in the thread
# actual:   select([r1, r2]) continues to wait

sleep 1
w2 << "foo"
# Making r2 readable resumes select([r1, r2])
# And it raises an exception: closed stream (IOError)

sleep 1

Incidentally, IO#read is resumed by closing the IO.

r1, w1 = IO.pipe

Thread.new do
  r1.read
  p :ok
end

sleep 1

p r1.close
# Closing r1 resumes r1.read in the thread
# And it raises: stream closed in another thread (IOError)

sleep 1

Related issues 1 (1 open0 closed)

Related to Ruby master - Bug #18455: `IO#close` has poor performance and difficult to understand semantics.Assignedioquatix (Samuel Williams)Actions
Actions

Also available in: Atom PDF

Like0
Like0