summaryrefslogtreecommitdiff
path: root/ext/socket
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket')
-rw-r--r--ext/socket/lib/socket.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb
index 0981b12edc..1099b7fd2f 100644
--- a/ext/socket/lib/socket.rb
+++ b/ext/socket/lib/socket.rb
@@ -607,7 +607,16 @@ class Socket
if st && st.socket? && st.owned?
File.unlink path
end
- Addrinfo.unix(path).listen
+ s = Addrinfo.unix(path).listen
+ if block_given?
+ begin
+ yield s
+ ensure
+ File.unlink path
+ end
+ else
+ s
+ end
end
# creates a UNIX socket server on _path_.