wait {fork} | R Documentation |
Wait for child process(es) created using 'fork' command to stop or terminate.
wait(pid, nohang=FALSE, untraced=FALSE)
pid |
integer indicating the set of child processes for
which status is requested. If missing or NULL , wait
for all child processes. |
nohang |
Use the WNOHANG flag. |
untraced |
Use the WUNTRACED flag. |
This function provides a thin wrapper around the Unix "wait" and
"waitpid" system calls. If pid
is missing or NULL
call, "wait" is called, otherwise "waitpid" is called.
Refer to the local Unix man pages for details on these system calls and the meanings of the various flags.
A vector of length 2 containing
pid |
Process id of a child process |
status |
Status of the child process. |
Refer to the local Unix man pages for details on these system calls
and the meanings of the status indicator.
Gregory R. Warnes warnes@bst.rochester.edu
"wait" and "waitpid" man pages
fork
, exit
, getpid
,
kill
, killall
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()