search for: myforkpar

Displaying 1 result from an estimated 1 matches for "myforkpar".

2009 Jul 11
1
Passing arguments to forked children
...t -- so definitely don't run in a CLI environment -- at least you can kill the parent window running R in a GUI environment). In any case, here is the code: # -- BEGIN CODE library("fork"); myforksub <- function(mymsg='default') { cat(mymsg,sep='\n'); exit(); } myforkparent <- function(n=10, mymsg='') { mypid <- c(); for (i in 1:n) { mypid <- c(mypid, fork(myforksub(mymsg))); } # wait(NULL) apparently does not wait for all children to finish for (i in 1:n) { wait(mypid[i]); } } myforkparent(mymsg='new'); # -- END CODE Ob...