[R] Auto-killing processes spawned by foreach::doMC

Steve Lianoglou mailinglist.honeypot at gmail.com
Wed Nov 3 22:55:16 CET 2010

Hi all,

Sometimes I'll find myself "ctrl-c"-ing like a madman to kill some
code that's parallelized via foreach/doMC when I realized that I just
set my cpu off to do something boneheaded, and it will keep doing that
thing for a while.

In these situations, since I interrupted its normal execution,
foreach/doMC doesn't "clean up" after itself by killing the processes
that were spawned. Furthermore, I believe that when I quit my "main" R
session, the spawned processes still remain (there, but idle).

I can go in via terminal (or some task manager/activity monitor) and
kill them manually, but does foreach (or something else (maybe
multicore?)) keep track of the process IDs that it spawned?

Is there some simple doCleanup() function I can write to get these R
processes and kill them automagically?

For what it's worth, I'm running on linux & os x, R-2.12 and the
latest versions of foreach/doMC/multicore (though, I feel like this
has been true since I've started using foreach/doMC way back when).


Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the R-help mailing list