Mercurial > forge
changeset 5701:01df1236689c octave-forge
reap children using waitpid, suggested by Travis Collier <travcollier@gmail.com>
author | highegg |
---|---|
date | Mon, 01 Jun 2009 07:54:14 +0000 |
parents | 291414cb3c2f |
children | 26e48505a398 |
files | main/general/inst/parcellfun.m |
diffstat | 1 files changed, 8 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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.