# HG changeset patch # User highegg # Date 1243842854 0 # Node ID 01df1236689cd5f3278a88f6cded1bcb74ceb343 # Parent 291414cb3c2f15be7fc865d50d0eda2dee918bc9 reap children using waitpid, suggested by Travis Collier diff -r 291414cb3c2f -r 01df1236689c main/general/inst/parcellfun.m --- a/main/general/inst/parcellfun.m Mon Jun 01 07:52:14 2009 +0000 +++ b/main/general/inst/parcellfun.m Mon Jun 01 07:54:14 2009 +0000 @@ -113,12 +113,15 @@ fflush (stdout); # prevent subprocesses from inheriting buffered output + pids = zeros (nproc, 1); + ## fork subprocesses for i = 1:nproc [pid, msg] = fork (); if (pid > 0) ## parent process. fork succeded. nsuc ++; + pids(i) = pid; elseif (pid == 0) ## child process. iproc = i; @@ -312,6 +315,11 @@ fclose (resr(i)); endfor + ## explicitly recognize all terminated processes. + for i = 1:nproc + [pid, status] = waitpid (pids(i)); + endfor + end_unwind_protect ## we're finished. transform the result.