From ce17a5ade0126c6b8d8ed4e07540e219fe15c8b4 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 21 Apr 1995 19:58:06 +0000 Subject: [PATCH] Change CLOSE-PORT to close the output side of an I/O port before it closes the input side. This matters when the same file channel is shared by both sides, and there is buffered data that must be flushed before the close. --- v7/src/runtime/genio.scm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/v7/src/runtime/genio.scm b/v7/src/runtime/genio.scm index e5f0a0c8e..e8579f3ef 100644 --- a/v7/src/runtime/genio.scm +++ b/v7/src/runtime/genio.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: genio.scm,v 1.4 1995/04/14 19:06:09 cph Exp $ +$Id: genio.scm,v 1.5 1995/04/21 19:58:06 cph Exp $ Copyright (c) 1991-95 Massachusetts Institute of Technology @@ -279,7 +279,12 @@ MIT in each case. |# (else (error:wrong-type-datum mode "terminal mode")))) (define (operation/close port) - (let ((input-buffer (port/input-buffer port))) - (if input-buffer (input-buffer/close input-buffer))) + ;; Must close output-buffer first, because it may need to flush + ;; buffered data, and there might only be one channel for both the + ;; input and output buffers. (let ((output-buffer (port/output-buffer port))) - (if output-buffer (output-buffer/close output-buffer)))) \ No newline at end of file + (if output-buffer + (output-buffer/close output-buffer))) + (let ((input-buffer (port/input-buffer port))) + (if input-buffer + (input-buffer/close input-buffer)))) \ No newline at end of file -- 2.25.1