fork
Version, currently main branch1 version
- main branchlatestJul 24, 2021
github.com/crystal-posix/fork.cr
libc's fork(2) for Crystal
2 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
fork:
github: crystal-posix/fork.cr
branch: mainmain is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
1.1.0- License
- MIT
- Author
- Postmodern
Dependencies
Development Dependencies
- spectator~> 0.9, >= 0.9.9gitlab: arctic-fox/spectatordev
README
fork.cr
Features
- Provides a
Fork.forkfunction. - Provides a
Fork.waitfunction. - Provides a
Fork.waitpidfunction.
Installation
-
Add the dependency to your
shard.yml:dependencies: fork: github: postmodern/fork.cr -
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
- 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
Contributors
- Postmodern - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
main- Seen
- Jul 24, 2021
- Crystal
1.1.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/crystal-posix/fork.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 14, 2026
- Synced
- Aug 14, 2026
- Versions
- 1