From fa14ae1312bd8a2444e7dbf72a94e79694aff218 Mon Sep 17 00:00:00 2001 From: Juho Snellman Date: Wed, 15 Mar 2006 04:03:26 +0000 Subject: [PATCH] 0.9.10.32: Make the streams created by RUN-PROGRAM bivalent. Patch by James Bielman on sbcl-devel, except: * Also bivalentify (bivalenticate? bivalentize?) the PTY stream * Add a test --- NEWS | 3 +++ src/code/run-program.lisp | 7 +++++-- tests/run-program.pure.lisp | 25 +++++++++++++++++++++++++ version.lisp-expr | 2 +- 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tests/run-program.pure.lisp diff --git a/NEWS b/NEWS index 37c364f..0401dcc 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,9 @@ changes in sbcl-0.9.11 relative to sbcl-0.9.10: * fixed bug: occasional GC crashes on Solaris/x86 * optimization: x86-64 supports stack allocation of results of simple calls of MAKE-ARRAY, bound to variables, declared DYNAMIC-EXTENT + * enchancement: the PROCESS-INPUT and -OUTPUT streams created by + SB-EXT:RUN-PROGRAM can be used for both character and byte IO + (thanks to James Bielman) changes in sbcl-0.9.10 relative to sbcl-0.9.9: * new feature: new SAVE-LISP-AND-DIE keyword argument :EXECUTABLE can diff --git a/src/code/run-program.lisp b/src/code/run-program.lisp index 18ad9f1..5088023 100644 --- a/src/code/run-program.lisp +++ b/src/code/run-program.lisp @@ -384,6 +384,7 @@ The function is called with PROCESS as its only argument.") (copy-descriptor-to-stream new-fd pty cookie))) (values name (sb-sys:make-fd-stream master :input t :output t + :element-type :default :dual-channel-p t))))) (defmacro round-bytes-to-words (n) @@ -777,12 +778,14 @@ colon-separated list of pathnames SEARCH-PATH" (:input (push read-fd *close-in-parent*) (push write-fd *close-on-error*) - (let ((stream (sb-sys:make-fd-stream write-fd :output t))) + (let ((stream (sb-sys:make-fd-stream write-fd :output t + :element-type :default))) (values read-fd stream))) (:output (push read-fd *close-on-error*) (push write-fd *close-in-parent*) - (let ((stream (sb-sys:make-fd-stream read-fd :input t))) + (let ((stream (sb-sys:make-fd-stream read-fd :input t + :element-type :default))) (values write-fd stream))) (t (sb-unix:unix-close read-fd) diff --git a/tests/run-program.pure.lisp b/tests/run-program.pure.lisp new file mode 100644 index 0000000..e67a1cf --- /dev/null +++ b/tests/run-program.pure.lisp @@ -0,0 +1,25 @@ +;;;; various run-program tests without side effects + +;;;; This software is part of the SBCL system. See the README file for +;;;; more information. +;;;; +;;;; While most of SBCL is derived from the CMU CL system, the test +;;;; files (like this one) were written from scratch after the fork +;;;; from CMU CL. +;;;; +;;;; This software is in the public domain and is provided with +;;;; absolutely no warranty. See the COPYING and CREDITS files for +;;;; more information. + +(cl:in-package :cl-user) + +(let* ((process (sb-ext:run-program "/bin/cat" '() :wait nil + :output :stream :input :stream)) + (out (process-input process)) + (in (process-output process))) + (unwind-protect + (loop for i from 0 to 255 do + (write-byte i out) + (force-output out) + (assert (= (read-byte in) i))) + (process-close process))) diff --git a/version.lisp-expr b/version.lisp-expr index 0ccb57c..5e800f1 100644 --- a/version.lisp-expr +++ b/version.lisp-expr @@ -17,4 +17,4 @@ ;;; checkins which aren't released. (And occasionally for internal ;;; versions, especially for internal versions off the main CVS ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".) -"0.9.10.31" +"0.9.10.32" -- 1.7.10.4