Shard Detail

ancillary v0.1.2

A crystal library that allows you to pass open file descriptors between processes
crystal crystal-lang

Install & Use

Add the following code to your project's shard.yml under:

dependencies to use in production
- OR -
development_dependencies to use in development


ancillary:
  github: 84codes/ancillary.cr

Readme

Ancillary

Allows you to pass open file descriptors between processes over an UNIX socket. It's a wrapper around libancillary.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      ancillary:
        github: 84codes/ancillary.cr
    
  2. Run shards install

Usage

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

Contributing

  1. Fork it (https://github.com/84codes/ancillary.cr/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors