diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-05-06 12:45:01 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-05-06 12:45:01 +0900 |
commit | 7397b9f7867b787280c1a5c955c40bd44fcb8f35 (patch) | |
tree | dcc2859337c703992d914d49f4ee24e956466f74 /test/socket | |
parent | 039a8ef78673f851e39b43980376c2af40d5cbbc (diff) | |
download | ruby-7397b9f7867b787280c1a5c955c40bd44fcb8f35.tar.gz |
Fixed leaked fds
Diffstat (limited to 'test/socket')
-rw-r--r-- | test/socket/test_unix.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index 6efb1d60ee..e9c90be167 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -542,16 +542,20 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase def test_getcred_xucred return if /freebsd|darwin/ !~ RUBY_PLATFORM - Dir.mktmpdir {|d| + Dir.mktmpdir do |d| sockpath = "#{d}/sock" serv = Socket.unix_server_socket(sockpath) - Socket.unix(sockpath) + u = Socket.unix(sockpath) s, = serv.accept cred = s.getsockopt(0, Socket::LOCAL_PEERCRED) inspect = cred.inspect assert_match(/ euid=#{Process.euid} /, inspect) assert_match(/ \(xucred\)/, inspect) - } + ensure + s&.close + u&.close + serv&.close + end end def test_sendcred_ucred |