Commit aa1e80b36d4b88374b77767c3e4e5e1b6c0d7c58

Thomas de Grivel 2018-04-17T15:51:07

close and open-p

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
diff --git a/unistd-stream.lisp b/unistd-stream.lisp
index f65df73..6cc9374 100644
--- a/unistd-stream.lisp
+++ b/unistd-stream.lisp
@@ -55,8 +55,12 @@
   '(unsigned-byte 8))
 
 (defmethod stream-close ((stream unistd-stream))
-  (unistd:close (stream-fd stream))
-  (call-next-method))
+  (unistd:close (stream-fd stream)))
+
+(defmethod stream-open-p ((stream unistd-stream))
+  (let ((fd (stream-fd stream)))
+    (unless (= -1 (unistd:c-dup2 fd fd))
+      t)))
 
 (defun compute-flags (read write append non-blocking create)
   (logior (if append              fcntl:+o-append+   0)