diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-10-03 12:16:36 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-10-03 03:16:39 +0000 |
| commit | 9bd2f30d0a73e5fd01aa80cfb5fd1c61b9ef64ff (patch) | |
| tree | ced21aca5fe6436f89c27a8a76f8700960a256bc | |
| parent | 75c4ac3395f609cad55a0e30a59d61ecfd092952 (diff) | |
[ruby/reline] Fix FD leaks (https://github.com/ruby/reline/pull/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>
```
https://github.com/ruby/reline/commit/f9f90da9e4
| -rw-r--r-- | test/reline/test_reline.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/reline/test_reline.rb b/test/reline/test_reline.rb index 22437eef9b..4134beac80 100644 --- a/test/reline/test_reline.rb +++ b/test/reline/test_reline.rb @@ -454,6 +454,9 @@ class Reline::Test < Reline::TestCase loop { break if r.readpartial(1024).include?("\e[6n") } w.puts "hello\e[10;#{ambiguous_width + 1}Rworld" assert_include(r.gets, [ambiguous_width, 'helloworld'].inspect) + ensure + r.close + w.close Process.waitpid pid end end @@ -463,6 +466,9 @@ class Reline::Test < Reline::TestCase loop { break if r.readpartial(1024).include?("\e[6n") } w.puts "hello\e[10;2Sworld" assert_include(r.gets, [1, "hello\e[10;2Sworld"].inspect) + ensure + r.close + w.close Process.waitpid pid end end |
