exit: Exit from a child process

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Exit from a child process.

Usage

1
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@warnes.net

References

"\_exit" man page

See Also

fork, getpid, wait, kill, killall

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
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()

warnes/fork documentation built on May 4, 2019, 12:59 a.m.