- Provides a
Fork.fork
function. - Provides a
Fork.wait
function. - Provides a
Fork.waitpid
function.
-
Add the dependency to your
shard.yml
:dependencies: fork: github: postmodern/fork.cr
-
Run
shards install
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}"
- Fork it (https://github.com/postmodern/fork/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Postmodern - creator and maintainer