Displaying 1 result from an estimated 1 matches for "myforksub".
2009 Jul 11
1
Passing arguments to forked children
...equal access to stdin, you cannot reliably type
commands into a given R session to terminate it -- 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...