The following minimal example...
require(Rmpi)
set.seed(1)
foo <- parallel::mclapply(seq_len(10), function(l)
lapply(1:10, function(x) mean(rnorm(10000, mean=x))),
mc.cores=4)
... produces warning messages of type
1: In selectChildren(ac, 1) : error 'Interrupted system call' in select
2: In selectChildren(ac, 1) : error 'Interrupted system call' in select
3: In selectChildren(ac, 1) : error 'Interrupted system call' in select
How can they be avoided?
I use Rmpi
and parallel
's mclapply
in a package, that's why I am asking. Note that this has been posted here but I haven't received an answer (yet). In case this matters, I work with Ubuntu 12.10, Emacs 24, and R 2.15.2
I see this problem with my Rmpi installation which was built using Open MPI 1.4.3. I assume you're also using Open MPI since you use Ubuntu. Loading Rmpi calls
MPI_Init
which causes theSIGCHLD
signal to be caught rather than ignored. I believe the result is thatSIGCHLD
will now be sent when child processes forked bymclapply
exit, which unexpectedly interruptsselect
system calls inmclapply
. If this doesn't cause any actual errors, you could prevent the warning messages by callingmclapply
insidesuppressWarnings
.There's a discussion of this issue in the Open MPI user's mailing list which suggests that the issue was fixed at some point in Open MPI 1.6 series, so the best solution to this problem may be to upgrade your MPI installation if you haven't already.
Update
I tried your example using Open MPI 1.6.5 and 1.7.3, but the problem persists. I decided to use the
inline
package to implement a function that resets theSIGCHLD
signal to the default handling. Using that I was able run your example without generating any warnings:Of course, it's possible that disabling the signal will cause some problems for Rmpi. In that case, you could modify the code to save and restore the
SIGCHLD
handler, but I don't know if that is necessary.