exit {fork}R Documentation

Exit from a child process

Description

Exit from a child process.

Usage

exit(status = 0)

Arguments

status Integer status flag. Use 0 for a normal exit.

Details

This function is a shallow warpper adound the Unix "_exit" command, and should be used instead of quit() to exit from a process created via fork.

Value

None.

Note

The fork command automatically sets up an on.exit function that calls exit before evaluating the slave argument, so it is usually not necessary to directly call exit().

Author(s)

Gregory R. Warnes greg@random-technologies-llc.com

References

"_exit" man page

See Also

fork, getpid, wait, kill, killall

Examples

waittest <- function()
{ 
  pid = fork(NULL)
  if(pid==0)
    {
      cat("Hi, I'm the child process and I need to explicitly call exit().")
      cat("\n\n")
      exit()
    }
  else
    {
      wait(pid)
      cat("Hi, I'm the main process, and I wait()ed until the child process\n")
      cat("finished before introducing myself.\n")
    }
}

waittest()

[Package fork version 1.2.1 Index]