fork.cr

libc's fork for Crystal.

Features

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      fork:
        github: postmodern/fork.cr
  2. Run shards install

Usage

require "fork"

if (pid = Fork.fork) == 0
  # running in child process

  # exit with status -1
  exit -1
else
  # running in parent process

  status = Fork.waitpid(pid) # wait for the child process to exit
  puts "Child process exiting with status: #{status}"
end

Using fork with a block:

status = Fork.fork do
  # running in child process

  # exit with status -1
  exit -1
end

puts "Child process exiting with status: #{status}"

Contributing

  1. Fork it (https://github.com/postmodern/fork/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