wait                  package:fork                  R Documentation

_W_a_i_t _f_o_r _c_h_i_l_d _p_r_o_c_e_s_s(_e_s) _t_o _s_t_o_p _o_r _t_e_r_m_i_n_a_t_e.

_D_e_s_c_r_i_p_t_i_o_n:

     Wait for child process(es) created using 'fork' command to stop or
     terminate.

_U_s_a_g_e:

     wait(pid, nohang=FALSE, untraced=FALSE)

_A_r_g_u_m_e_n_t_s:

     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.

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

     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.

_A_u_t_h_o_r(_s):

     Gregory R. Warnes gregory_r_warnes\@groton.pfizer.com

_R_e_f_e_r_e_n_c_e_s:

     "wait" and "waitpid"  man pages

_S_e_e _A_l_s_o:

     'fork', 'exit', 'getpid', 'kill', 'killall'

_E_x_a_m_p_l_e_s:

     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()

