diff --git a/src/c/unixsys.d b/src/c/unixsys.d index ec71df376..b54a31cb0 100644 --- a/src/c/unixsys.d +++ b/src/c/unixsys.d @@ -318,12 +318,6 @@ create_descriptor(cl_object stream, cl_object direction, if (*parent < 0) printf("open_osfhandle failed\n"); } - else if (Null(stream)) { - if (direction == @':input') - *child = open("nul", O_RDONLY); - else - *child = open("nul", O_WRONLY); - } else if (!Null(cl_streamp(stream))) { HANDLE stream_handle = ecl_stream_to_HANDLE (stream, direction != @':input'); @@ -357,12 +351,6 @@ create_descriptor(cl_object stream, cl_object direction, *child = fd[1]; } } - else if (Null(stream)) { - if (direction == @':input') - *child = open("/dev/null", O_RDONLY); - else - *child = open("/dev/null", O_WRONLY); - } else if (!Null(cl_streamp(stream))) { *child = ecl_stream_to_handle (stream, direction != @':input'); diff --git a/src/lsp/process.lsp b/src/lsp/process.lsp index c2f443f15..0e2a5064e 100644 --- a/src/lsp/process.lsp +++ b/src/lsp/process.lsp @@ -143,36 +143,36 @@ (unless (ext:get-signal-handler ext:+sigchld+) (ext:set-signal-handler ext:+sigchld+ #'sigchld-handler)) - (flet ((process-stream (which default &rest args) - (cond ((eql which t) default) - ((or (stringp which) (pathnamep which)) - (apply #'open which :external-format external-format args)) - ;; this three cases are handled in create_descriptor (for now) - ((eql which nil) which) - ((eql which :stream) which) - ((streamp which) which) - ;; signal error as early as possible - (T (error "Invalid ~S argument to EXT:RUN-PROGRAM" which)))) - - (prepare-args (args) - #-windows - (mapcar #'si:copy-to-simple-base-string args) - #+windows - (si:copy-to-simple-base-string - (with-output-to-string (str) - (loop for (arg . rest) on args - do (if (and escape-arguments - (find-if (lambda (c) - (find c '(#\Space #\Tab #\"))) - arg)) - (escape-arg arg str) - (princ arg str)) - (when rest - (write-char #\Space str)))))) - (null-stream (direction) - (open #-windows "/dev/null" - #+windows "nul" - :direction direction))) + (labels ((process-stream (which default &rest args) + (cond ((eql which t) + default) + ((or (stringp which) (pathnamep which)) + (apply #'open which :external-format external-format args)) + ((eql which nil) + (null-stream (getf args :direction))) + ((or (eql which :stream) (streamp which)) + which) + ;; signal error as early as possible + (T (error "Invalid ~S argument to EXT:RUN-PROGRAM" which)))) + (prepare-args (args) + #-windows + (mapcar #'si:copy-to-simple-base-string args) + #+windows + (si:copy-to-simple-base-string + (with-output-to-string (str) + (loop for (arg . rest) on args + do (if (and escape-arguments + (find-if (lambda (c) + (find c '(#\Space #\Tab #\"))) + arg)) + (escape-arg arg str) + (princ arg str)) + (when rest + (write-char #\Space str)))))) + (null-stream (direction) + (open #-windows "/dev/null" + #+windows "nul" + :direction direction))) (setf input (process-stream input *standard-input* :direction :input