Project

General

Profile

Actions

Bug #21495

open

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

Added by dE (dE Techno) about 9 hours ago. Updated about 9 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 #1

Updated by dE (dE Techno) about 9 hours ago

  • ruby -v changed from de@myworkstation ~/docs/Practice/Software/ruby $ ruby -v ruby 3.2.8 (2025-03-26 revision 13f495dc2c) [x86_64-linux] to ruby -v ruby 3.2.8 (2025-03-26 revision 13f495dc2c) [x86_64-linux]
Actions #2

Updated by dE (dE Techno) about 9 hours ago

  • ruby -v changed from ruby -v ruby 3.2.8 (2025-03-26 revision 13f495dc2c) [x86_64-linux] to ruby 3.2.8 (2025-03-26 revision 13f495dc2c) [x86_64-linux]
Actions

Also available in: Atom PDF

Like0
Like0Like0