From c3be428c452fd9c91d31b5b7d5b697175b6652df Mon Sep 17 00:00:00 2001 From: Hleb Valoshka <375gnu@gmail.com> Date: Sat, 7 Sep 2013 23:07:36 +0300 Subject: Close tempfile and unlink it immediately. When a Tempfile object is garbage collected, or when the Ruby interpreter exits, its associated temporary file is automatically deleted. This may lead to race condition when Tempfile is used like in these tests. Signed-off-by: Eric Wong --- test/test_unix_connect.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'test/test_unix_connect.rb') diff --git a/test/test_unix_connect.rb b/test/test_unix_connect.rb index 60cb8c0..7b19941 100644 --- a/test/test_unix_connect.rb +++ b/test/test_unix_connect.rb @@ -18,8 +18,7 @@ class TestKgioUnixConnect < Test::Unit::TestCase @tmpdir = Dir.mktmpdir('kgio_unix_1') tmp = Tempfile.new('kgio_unix_1', @tmpdir) @path = tmp.path - File.unlink(@path) - tmp.close rescue nil + tmp.close! @srv = Kgio::UNIXServer.new(@path) @addr = Socket.pack_sockaddr_un(@path) end -- cgit v1.2.3-24-ge0c7