Skip to content

Instantly share code, notes, and snippets.

@tagomoris
Last active January 25, 2017 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tagomoris/5bc1b618c5196c693a7b096353eb57e4 to your computer and use it in GitHub Desktop.
Save tagomoris/5bc1b618c5196c693a7b096353eb57e4 to your computer and use it in GitHub Desktop.
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby hoge.rb
{:here=>"rescue", :closed=>true, :error=>#<IOError: stream closed>}
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby -e 'puts RUBY_VERSION'
2.3.3
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux-gnu]
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby hoge.rb
{:here=>"rescue", :closed=>true, :error=>#<IOError: stream closed>}
MBA:fluentd tagomoris$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15]
MBA:fluentd tagomoris$ ruby hoge.rb
{:here=>"rescue", :closed=>true, :error=>#<Errno::EBADF: Bad file descriptor>}
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby -v
ruby 2.5.0dev (2017-01-25 trunk 57420) [x86_64-linux]
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby hoge.rb
{:here=>"rescue", :closed=>false, :error=>#<IOError: stream closed>}
MBA:fluentd tagomoris$ ruby -v
ruby 2.5.0dev (2017-01-24 trunk 57413) [x86_64-darwin15]
MBA:fluentd tagomoris$ ruby hoge.rb
{:here=>"rescue", :closed=>true, :error=>#<Errno::EBADF: Bad file descriptor>}
require 'socket'
server = UNIXServer.new('/tmp/yaaaay')
thread = Thread.new do
begin
while sock = server.accept
p(here: "accepted", sock: sock)
sock.close rescue nil
end
rescue => e
p(here: "rescue", closed: server.closed?, error: e)
end
end
sleep 1
server.close
sleep 1
File.delete('/tmp/yaaaay')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment