Project

General

Profile

Actions

Bug #21495

open

IO.read_nonblock does not work under a rescue IO::TimeoutError

Added by dE (dE Techno) about 16 hours ago. Updated about 15 hours ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.8 (2025-03-26 revision 13f495dc2c) [x86_64-linux]
[ruby-core:122636]

Description

In this particular code --

execArg = 'echo testwrite; sleep 5'
tofuProcess = IO.popen(execArg, 'r')
puts 'executed tofu process.'
tofuProcess.timeout=2
begin
	tofuOut = tofuProcess.read
rescue IO::TimeoutError
	puts 'rescue occured'
	begin
		tofuOut = tofuProcess.read_nonblock(1)
	rescue IO::EAGAINWaitReadable
		puts 'no data in read buffer!'
	end
	tofuProcess.close
	puts 'process closed'
end

tofuProcess.read_nonblock(1) must return a character because the underlying process has produced an output. But it raises a IO::EAGAINWaitReadable exception instead which does not happen outside a rescue IO::TimeoutError block

Actions

Also available in: Atom PDF

Like0
Like0Like0