Commit f2bf65a4a3434ce8c4a7b0187635d921b07aa4bf

Thomas de Grivel 2017-06-23T21:26:30

dup

diff --git a/cffi-unistd.lisp b/cffi-unistd.lisp
index f5e1098..8083cf7 100644
--- a/cffi-unistd.lisp
+++ b/cffi-unistd.lisp
@@ -112,3 +112,12 @@ or number of bytes written otherwise."
      (unwind-protect (progn ,@body)
        (close ,out-var)
        (close ,in-var))))
+
+(defcfun ("dup" c-dup) :int
+  (oldfd :int))
+
+(defun dup (oldfd)
+  (let ((r (c-dup oldfd)))
+    (when (< r 0)
+      (error-errno "dup"))
+    r))
diff --git a/package.lisp b/package.lisp
index 25de2c5..9b54c96 100644
--- a/package.lisp
+++ b/package.lisp
@@ -44,4 +44,4 @@
    #:c-pipe
    #:pipe
    #:with-pipe
-   ))
+   #:dup))