Skip to content

Commit f9f90da

Browse files
authored
Fix FD leaks (#752)
`PTY.spawn` with a block detaches the spawned process and leaves it running in background even after exiting the given block. It is the responsibility of the caller to clean up the yielded IOs and PID. https://github.com/ruby/ruby/actions/runs/11148759246/job/30986064044#step:13:950 ``` Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 9 : #<File:/dev/pts/0> Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 10 : #<File:/dev/pts/0> Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 11 : #<File:/dev/pts/1> Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 12 : #<File:/dev/pts/1> Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 13 : #<File:/dev/pts/2> Leaked file descriptor: Reline::Test#test_tty_amibuous_width: 14 : #<File:/dev/pts/2> ```
1 parent bf0f8fa commit f9f90da

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

test/reline/test_reline.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ def test_tty_amibuous_width
454454
loop { break if r.readpartial(1024).include?("\e[6n") }
455455
w.puts "hello\e[10;#{ambiguous_width + 1}Rworld"
456456
assert_include(r.gets, [ambiguous_width, 'helloworld'].inspect)
457+
ensure
458+
r.close
459+
w.close
457460
Process.waitpid pid
458461
end
459462
end
@@ -463,6 +466,9 @@ def test_tty_amibuous_width
463466
loop { break if r.readpartial(1024).include?("\e[6n") }
464467
w.puts "hello\e[10;2Sworld"
465468
assert_include(r.gets, [1, "hello\e[10;2Sworld"].inspect)
469+
ensure
470+
r.close
471+
w.close
466472
Process.waitpid pid
467473
end
468474
end

0 commit comments

Comments
 (0)