fork: Fork a new process

Description Usage Arguments See Also Examples

View source: R/bfork.R

Description

Create a new process given a function.

Usage

1
    fork(fn)

Arguments

fn

a function that takes no arguments and returns no arguments that will be run in a new process

See Also

wait.
waitpid.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
    ## create a function to be run as a separate process
    fn <- function() {
        Sys.sleep(4)
        print("World!")
    }

    ## fork the process
    pid <- fork(fn)

    ## do work in the parent process
    print("Hello")

    ## wait for the child process
    waitpid(pid)

bfork documentation built on May 29, 2017, 10:01 p.m.