Commit 06389326 authored by Marius Gerbershagen's avatar Marius Gerbershagen
Browse files

run-program: remove redundant finalizer for windows handles

We have already registered a finalizer for the external process object
which calls external-process-wait. This in turn calls si::waitpid
which closes the handle once the process has exited.
parent ddb7bb72
......@@ -2069,7 +2069,6 @@ cl_symbols[] = {
{SYS_ "RUN-PROGRAM-INNER" ECL_FUN("si_run_program_inner", si_run_program_inner, 4) ECL_VAR(SI_ORDINARY, OBJNULL)},
{SYS_ "SPAWN-SUBPROCESS" ECL_FUN("si_spawn_subprocess", si_spawn_subprocess, 6) ECL_VAR(SI_ORDINARY, OBJNULL)},
{SYS_ "CLOSE-WINDOWS-HANDLE" ECL_FUN("si_close_windows_handle", IF_WINDOWS(si_close_windows_handle), 1) ECL_VAR(SI_ORDINARY, OBJNULL)},
/* ~ */
......@@ -214,15 +214,6 @@ si_killpid(cl_object pid, cl_object signal) {
#if defined(ECL_MS_WINDOWS_HOST)
si_close_windows_handle(cl_object h)
if (ecl_t_of(h) == t_foreign) {
HANDLE *ph = (HANDLE*)h->;
if (ph) CloseHandle(*ph);
static cl_object
make_windows_handle(HANDLE h)
......@@ -230,7 +221,6 @@ make_windows_handle(HANDLE h)
HANDLE *ph = (HANDLE*)foreign->;
*ph = h;
si_set_finalizer(foreign, @'si::close-windows-handle');
return foreign;
......@@ -1954,7 +1954,6 @@ extern ECL_API void ecl_check_pending_interrupts(cl_env_ptr env);
extern ECL_API cl_object si_system(cl_object cmd);
extern ECL_API cl_object si_make_pipe();
extern ECL_API cl_object si_run_program _ECL_ARGS((cl_narg narg, cl_object command, cl_object args, ...));
extern ECL_API cl_object si_close_windows_handle(cl_object h);
extern ECL_API cl_object si_terminate_process _ECL_ARGS((cl_narg narg, cl_object process, ...));
extern ECL_API cl_object si_waitpid(cl_object pid, cl_object wait);
extern ECL_API cl_object si_killpid(cl_object pid, cl_object signal);
......@@ -98,6 +98,9 @@
;;; We don't handle `sigchld' because we don't want races with
;;; `external-process-wait'. Take care of forgotten processes.
(defun finalize-external-process (process)
;; INV: this finalizer also closes the process handle on windows
;; since external-process-wait calls si:waitpid which closes the
;; handle once the process has exited.
(unless (member (ext:external-process-wait process nil)
'(:exited :signaled :abort :error))
(ext:set-finalizer process #'finalize-external-process)))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment