diff --git a/collects/scribblings/reference/subprocess.scrbl b/collects/scribblings/reference/subprocess.scrbl index 8a9e25d585..8de58c04b5 100644 --- a/collects/scribblings/reference/subprocess.scrbl +++ b/collects/scribblings/reference/subprocess.scrbl @@ -73,11 +73,7 @@ The @scheme[subprocess] procedure returns four values: @bold{Important:} All ports returned from @scheme[subprocess] must be explicitly closed with @scheme[close-input-port] or -@scheme[close-output-port]. Similarly, waiting on the subprocess value -(using @scheme[subprocess-wait] or @scheme[sync]) ensures that the -operating system can release the subprocess; for example, -exiting without waiting on a subprocess under Unix risks leaving the -subprocess as a zombie. +@scheme[close-output-port]. The returned ports are @tech{file-stream ports} (see @secref["file-ports"]), and they are placed into the management of diff --git a/src/mzscheme/src/port.c b/src/mzscheme/src/port.c index e81c3fd709..4723887596 100644 --- a/src/mzscheme/src/port.c +++ b/src/mzscheme/src/port.c @@ -6814,6 +6814,8 @@ static int MyPipe(int *ph, int near_index) { # define GC_write_barrier(x) /* empty */ #endif +static int need_to_check_children; + #ifdef MZ_XFORM START_XFORM_SKIP; #endif @@ -6832,6 +6834,7 @@ void scheme_block_child_signals(int block) static void child_done(int ingored) { + need_to_check_children = 1; scheme_signal_received(); # ifdef SIGSET_NEEDS_REINSTALL @@ -6896,6 +6899,14 @@ static void check_child_done() } } +void scheme_check_child_done(void) +{ + if (need_to_check_children) { + need_to_check_children = 0; + check_child_done(); + } +} + #endif /*========================================================================*/ diff --git a/src/mzscheme/src/schpriv.h b/src/mzscheme/src/schpriv.h index fe4b8f9660..9ce9355243 100644 --- a/src/mzscheme/src/schpriv.h +++ b/src/mzscheme/src/schpriv.h @@ -414,6 +414,7 @@ void scheme_start_itimer_thread(long usec); #ifdef UNIX_PROCESSES void scheme_block_child_signals(int block); +void scheme_check_child_done(void); #endif Scheme_Object **scheme_alloc_runstack(long len); diff --git a/src/mzscheme/src/thread.c b/src/mzscheme/src/thread.c index 452993133d..6b5de666ee 100644 --- a/src/mzscheme/src/thread.c +++ b/src/mzscheme/src/thread.c @@ -4088,6 +4088,11 @@ void scheme_thread_block(float sleep_time) /* Check scheduled_kills early and often. */ check_scheduled_kills(); +#ifdef UNIX_PROCESSES + /* Reap zombie processes: */ + scheme_check_child_done(); +#endif + shrink_cust_box_array(); if (scheme_active_but_sleeping)