Commit 8ca54841ed698d30b75916861382f0db566bbc74

Thomas de Grivel 2018-06-04T10:01:51

only close fd if still open

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/unistd-stream.lisp b/unistd-stream.lisp
index 6cc9374..e37a39d 100644
--- a/unistd-stream.lisp
+++ b/unistd-stream.lisp
@@ -55,7 +55,8 @@
   '(unsigned-byte 8))
 
 (defmethod stream-close ((stream unistd-stream))
-  (unistd:close (stream-fd stream)))
+  (when (stream-open-p stream)
+    (unistd:close (stream-fd stream))))
 
 (defmethod stream-open-p ((stream unistd-stream))
   (let ((fd (stream-fd stream)))