diff --git a/src/c/symbols_list.h b/src/c/symbols_list.h index ccf974086..904ae9f67 100755 --- a/src/c/symbols_list.h +++ b/src/c/symbols_list.h @@ -1233,6 +1233,7 @@ cl_symbols[] = { {SYS_ "REPLACE-ARRAY", SI_ORDINARY, si_replace_array, 2, OBJNULL}, {SYS_ "ROW-MAJOR-ASET", SI_ORDINARY, si_row_major_aset, 3, OBJNULL}, {EXT_ "RUN-PROGRAM", EXT_ORDINARY, ECL_NAME(si_run_program), -1, OBJNULL}, +{SYS_ "WAITPID", SI_ORDINARY, si_waitpid, 2, OBJNULL}, {SYS_ "RUN-PROGRAM-INNER", SI_ORDINARY, si_run_program_inner, 3, OBJNULL}, {SYS_ "SPAWN-SUBPROCESS", SI_ORDINARY, si_spawn_subprocess, 6, OBJNULL}, {EXT_ "TERMINATE-PROCESS", EXT_ORDINARY, si_terminate_process, -1, OBJNULL}, diff --git a/src/c/symbols_list2.h b/src/c/symbols_list2.h index 3e3e5e24f..47850587e 100644 --- a/src/c/symbols_list2.h +++ b/src/c/symbols_list2.h @@ -1233,6 +1233,7 @@ cl_symbols[] = { {SYS_ "REPLACE-ARRAY","si_replace_array"}, {SYS_ "ROW-MAJOR-ASET","si_row_major_aset"}, {EXT_ "RUN-PROGRAM","ECL_NAME(si_run_program)"}, +{SYS_ "WAITPID","si_waitpid"}, {SYS_ "RUN-PROGRAM-INNER","si_run_program_inner"}, {SYS_ "SPAWN-SUBPROCESS","si_spawn_subprocess"}, {EXT_ "TERMINATE-PROCESS","si_terminate_process"}, diff --git a/src/c/unixsys.d b/src/c/unixsys.d index 7d89d8a39..4896f97c0 100644 --- a/src/c/unixsys.d +++ b/src/c/unixsys.d @@ -145,12 +145,6 @@ from_list_to_execve_argument(cl_object l, char ***environp) return buffer; } -static cl_object -external_process_pid(cl_object p) -{ - return ecl_structure_ref(p, @'ext::external-process', 0); -} - cl_object si_waitpid(cl_object pid, cl_object wait) { @@ -220,7 +214,7 @@ si_waitpid(cl_object pid, cl_object wait) cl_env_ptr env = ecl_process_env(); bool error_encountered = FALSE; - cl_object pid = external_process_pid(process); + cl_object pid = ecl_structure_ref(process, @'ext::external-process', 0); if (!Null(pid)) { int ret; #if defined(ECL_MS_WINDOWS_HOST) diff --git a/src/cmp/proclamations.lsp b/src/cmp/proclamations.lsp index 42813d01f..aecf456d7 100644 --- a/src/cmp/proclamations.lsp +++ b/src/cmp/proclamations.lsp @@ -1329,6 +1329,10 @@ (values (or null two-way-stream) (or null integer) ext:external-process)) +(proclamation si:waitpid (fixnum gen-bool) (values + (or null keyword) + (or null fixnum) + (or null fixnum))) (proclamation si:run-program-inner (string (or list string) list) (values two-way-stream integer)) (proclamation si:spawn-subprocess (string (or list string) list t t t) diff --git a/src/h/external.h b/src/h/external.h index c5a988d7f..ac8160277 100755 --- a/src/h/external.h +++ b/src/h/external.h @@ -1884,9 +1884,17 @@ 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_external_process_wait _ECL_ARGS((cl_narg narg, cl_object h, ...)); 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_run_program_inner +(cl_object command, cl_object argv, cl_object environ); + +extern ECL_API cl_object si_spawn_subprocess +(cl_object command, cl_object argv, cl_object environ, + cl_object input, cl_object output, cl_object error); + /* unicode -- no particular file, but we group these changes here */ diff --git a/src/h/internal.h b/src/h/internal.h index 3c4d2c757..f7209c22b 100755 --- a/src/h/internal.h +++ b/src/h/internal.h @@ -526,14 +526,6 @@ extern cl_object mp_get_rwlock_write_wait(cl_object lock); extern void ecl_interrupt_process(cl_object process, cl_object function); /* unixsys.d */ -extern cl_object si_waitpid(cl_object pid, cl_object wait); - -extern cl_object si_run_program_inner -(cl_object command, cl_object argv, cl_object environ); - -extern cl_object si_spawn_subprocess -(cl_object command, cl_object argv, cl_object environ, - cl_object input, cl_object output, cl_object error); /* * Fake several ISO C99 mathematical functions if not available diff --git a/src/lsp/process.lsp b/src/lsp/process.lsp index 545f10acf..fdfe900be 100644 --- a/src/lsp/process.lsp +++ b/src/lsp/process.lsp @@ -30,7 +30,7 @@ (values status (external-process-%code external-process))))) ;;; --------------------------------------------------------------------------- -;;; ecl-waitpid -> (values status code pid) +;;; si:waitpid -> (values status code pid) ;;; --------------------------------------------------------------------------- ;;; nochg :: (values nil nil nil) ;;; error :: (values (member :abort :error) nil nil) @@ -39,9 +39,9 @@ (defun external-process-wait (process &optional wait) (let ((pid (external-process-pid process))) (when pid - (multiple-value-bind (status code pid) (ecl-waitpid pid wait) + (multiple-value-bind (status code pid) (si:waitpid pid wait) (unless (and wait (null status) (null code) (null pid)) - (setf (external-process-pid process) nil + (setf (external-process-pid process) pid (external-process-%status process) status (external-process-%code process) code))))) (values (external-process-%status process) @@ -196,11 +196,6 @@ "ecl_make_stream_from_fd(#0, #1, ecl_smm_output, 8, ECL_STREAM_DEFAULT_FORMAT, #2)" :one-liner t)) -(defun ecl-waitpid (pid wait) - (ffi:c-inline - (pid wait) (:object :object) (values :object :object :object) - "si_waitpid(#0, #1)" :one-liner t)) - (defun null-stream () (ffi:c-inline () () :object "cl_core.null_stream" :one-liner t :side-effects nil))