Add the following code to your project's shard.yml under:
dependencies
to use in production
- OR -
development_dependencies
to use in development
Allows you to pass open file descriptors between processes over an UNIX socket. It's a wrapper around libancillary.
Add the dependency to your shard.yml
:
dependencies:
ancillary:
github: 84codes/ancillary.cr
Run shards install
On one side:
require "ancillary"
file = File.open("/tmp/file", "w")
UNIXServer.open("/tmp/fd-passing") do |s|
while client = s.accept?
ancil = Ancillary.new(client)
ancil.send(file.fd)
end
end
On the other side:
require "ancillary"
s = UNIXSocket.new("/tmp/fd-passing")
ancil = Ancillary.new(s)
fd = ancil.receive
io = IO::FileDescriptor.new(fd)
io.print "foo"
io.close
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)