From: Stelian Ionescu Date: Tue, 2 Apr 2013 19:55:05 +0000 (+0200) Subject: SETUP-SLAVE-PTY: close PTY in case of error X-Git-Tag: v0.8.1~74 X-Git-Url: https://repo.or.cz/w/iolib.git/commitdiff_plain/ccc69bd32315add12fe0376fe6f5fd3f6f334886 SETUP-SLAVE-PTY: close PTY in case of error --- diff --git a/src/os/create-process-unix.lisp b/src/os/create-process-unix.lisp index 0bc18c1..41a1d67 100644 --- a/src/os/create-process-unix.lisp +++ b/src/os/create-process-unix.lisp @@ -223,10 +223,14 @@ (defun setup-slave-pty (new-ctty-p) (if new-ctty-p - (let ((ptmfd (isys:openpt (logior isys:o-rdwr isys:o-noctty isys:o-cloexec)))) - (isys:grantpt ptmfd) - (isys:unlockpt ptmfd) - (values ptmfd (isys:ptsname ptmfd))) + (let (ptmfd) + (unwind-protect-case () + (progn + (setf ptmfd (isys:openpt (logior isys:o-rdwr isys:o-noctty isys:o-cloexec))) + (isys:grantpt ptmfd) + (isys:unlockpt ptmfd) + (values ptmfd (isys:ptsname ptmfd))) + (:abort (when ptmfd (isys:close ptmfd))))) (values nil nil))) (defmacro with-pty ((new-ctty-p ptmfd pts) &body body)