Created
October 1, 2013 08:24
-
-
Save navaneeth/6775384 to your computer and use it in GitHub Desktop.
JRuby Fork implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module Exec | |
extend FFI::Library | |
ffi_lib FFI::Library::LIBC | |
attach_function :fork, [], :int | |
end | |
def fork | |
pid = Exec.fork | |
if pid == 0 | |
yield if block_given? | |
return nil | |
else | |
return pid | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment