search for: is_forked

Displaying 2 results from an estimated 2 matches for "is_forked".

2017 Jan 25
2
parallel::mc*: Is it possible for a child process to know it is a fork?
When using multicore-forking of the parallel package, is it possible for a child process to know that it is a fork? Something like: parallel::mclapply(1:10, FUN = function(i) { test_if_running_in_a_fork() }) I'm looking into ways to protect against further parallel processes (including threads), which not necessarily are created via the parallel:mc* API, are being spawned off recursively.
2017 Jan 25
0
parallel::mc*: Is it possible for a child process to know it is a fork?
...of the parallel package, is it possible > for a child process to know that it is a fork? R internally uses R_isForkedChild to prevent certain operations within the fork. However I don't think this is exported anywhere. You could do something like: extern Rboolean R_isForkedChild; SEXP is_forked(){ return ScalarLogical(R_isForkedChild); } But that won't be allowed on CRAN: * checking compiled code ... NOTE Found non-API call to R: ?R_isForkedChild? Compiled code should not call non-API entry points in R. Another method would be to look at getppid(2) and getpgid(2) to looku...