Checking is serial device already opened before call `%sys-open`

Nikolay V. Razbegaev [2010-02-13 10:05]
Checking is serial device already opened before call `%sys-open`
Filename
bugs/issue-b45b66aced0aa0280a541978d4b839620748f2c1.yaml
streams.lisp
diff --git a/bugs/issue-b45b66aced0aa0280a541978d4b839620748f2c1.yaml b/bugs/issue-b45b66aced0aa0280a541978d4b839620748f2c1.yaml
index d6b0b0d..28a724e 100644
--- a/bugs/issue-b45b66aced0aa0280a541978d4b839620748f2c1.yaml
+++ b/bugs/issue-b45b66aced0aa0280a541978d4b839620748f2c1.yaml
@@ -5,8 +5,8 @@ type: :feature
 component: iolib.termios
 release: v0.1
 reporter: Nikolay V. Razbegaev <marsijanin@gmail.com>
-status: :unstarted
-disposition:
+status: :closed
+disposition: :fixed
 creation_time: 2010-02-13 09:51:37.458083 Z
 references: []

@@ -16,3 +16,7 @@ log_events:
   - Nikolay V. Razbegaev <marsijanin@gmail.com>
   - created
   - ""
+- - 2010-02-13 10:03:19.261235 Z
+  - Nikolay V. Razbegaev <marsijanin@gmail.com>
+  - closed with disposition fixed
+  - ""
diff --git a/streams.lisp b/streams.lisp
index 12d0174..99e15e8 100644
--- a/streams.lisp
+++ b/streams.lisp
@@ -25,6 +25,10 @@
 			(external-format :default))
   "Return `dual-channel-tty-gray-stream' instances associated
    with serial device and push in into the `*open-serial-streams*' list"
+  (when (find-if #'(lambda (x)
+                     (string= (tty-path x) path))
+                 *open-serial-streams*)
+    (error "Serial device ~A already opened!" path))
   (let ((fd (%sys-open path flag mode))
         (termios (foreign-alloc 'termios)))
     (%tcgetattr fd termios)
ViewGit