master: Add c_ispeed and c_ospeed fields to sb-posix:termios
stassats via Sbcl-commits <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via 7c5b07f38a096ea2d0fbb89203b2c48ca671ad8b (commit)
from 25215818e222bf2f3292c005f9642b202d99cf31 (commit)
- Log -----------------------------------------------------------------
commit 7c5b07f38a096ea2d0fbb89203b2c48ca671ad8b
Author: Stas Boukarev <[email protected]>
Date: Tue Apr 28 14:01:14 2026 +0300
Add c_ispeed and c_ospeed fields to sb-posix:termios
Should fix a problem with OpenBSD.
Based on a patch by Robert Palm.
Fixes lp#2150499
---
contrib/sb-posix/constants.lisp | 4 +++-
contrib/sb-posix/defpackage.lisp | 4 +++-
contrib/sb-posix/interface.lisp | 16 ++++++++++------
contrib/sb-posix/posix-tests.lisp | 27 +++++++++++++++++++++++++++
4 files changed, 43 insertions(+), 8 deletions(-)
diff --git a/contrib/sb-posix/constants.lisp b/contrib/sb-posix/constants.lisp
index 14255e9a3..26a16d36a 100644
--- a/contrib/sb-posix/constants.lisp
+++ b/contrib/sb-posix/constants.lisp
@@ -433,7 +433,9 @@
(tcflag-t oflag "tcflag_t" "c_oflag")
(tcflag-t cflag "tcflag_t" "c_cflag")
(tcflag-t lflag "tcflag_t" "c_lflag")
- ((array cc-t) cc "cc_t" "c_cc")))
+ ((array cc-t) cc "cc_t" "c_cc")
+ (speed-t ispeed "speed_t" "c_ispeed")
+ (speed-t ospeed "speed_t" "c_ospeed")))
;; utime(), utimes()
#-win32
diff --git a/contrib/sb-posix/defpackage.lisp b/contrib/sb-posix/defpackage.lisp
index 8076c9bc1..ee082b912 100644
--- a/contrib/sb-posix/defpackage.lisp
+++ b/contrib/sb-posix/defpackage.lisp
@@ -20,7 +20,9 @@
#:stat-gid #:stat-size #:stat-atime #:stat-mtime #:stat-ctime
#:stat-rdev
#:termios-iflag #:termios-oflag #:termios-cflag
- #:termios-lflag #:termios-cc #:timeval-sec #:timeval-usec
+ #:termios-lflag #:termios-cc
+ #:termios-ispeed #:termios-ospeed
+ #:timeval-sec #:timeval-usec
#:flock-type #:flock-whence #:flock-start #:flock-len
#:flock-pid
diff --git a/contrib/sb-posix/interface.lisp b/contrib/sb-posix/interface.lisp
index 58838d129..416c8ece8 100644
--- a/contrib/sb-posix/interface.lisp
+++ b/contrib/sb-posix/interface.lisp
@@ -813,16 +813,20 @@ not supported."
#-win32
(define-protocol-class termios alien-termios ()
- ((iflag :initarg :iflag :accessor sb-posix:termios-iflag
+ ((iflag :initarg :iflag :accessor termios-iflag
:documentation "Input modes.")
- (oflag :initarg :oflag :accessor sb-posix:termios-oflag
+ (oflag :initarg :oflag :accessor termios-oflag
:documentation "Output modes.")
- (cflag :initarg :cflag :accessor sb-posix:termios-cflag
+ (cflag :initarg :cflag :accessor termios-cflag
:documentation "Control modes.")
- (lflag :initarg :lflag :accessor sb-posix:termios-lflag
+ (lflag :initarg :lflag :accessor termios-lflag
:documentation "Local modes.")
- (cc :initarg :cc :accessor sb-posix:termios-cc :array-length nccs
- :documentation "Control characters."))
+ (cc :initarg :cc :accessor termios-cc :array-length nccs
+ :documentation "Control characters.")
+ (ispeed :initarg :ispeed :accessor termios-ispeed
+ :documentation "Input speed.")
+ (ospeed :initarg :ospeed :accessor termios-ospeed
+ :documentation "Output speed."))
(:documentation
"Instances of this class represent I/O characteristics of the terminal."))
diff --git a/contrib/sb-posix/posix-tests.lisp b/contrib/sb-posix/posix-tests.lisp
index 916f5e568..080c0d891 100644
--- a/contrib/sb-posix/posix-tests.lisp
+++ b/contrib/sb-posix/posix-tests.lisp
@@ -18,6 +18,14 @@
sb-posix::s-irgrp sb-posix::s-iwgrp sb-posix::s-ixgrp
sb-posix::s-iroth sb-posix::s-iwoth sb-posix::s-ixoth))))
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (sb-alien:define-alien-routine openpty sb-alien:int
+ (amaster sb-alien:int :out)
+ (aslave sb-alien:int :out)
+ (name (* sb-alien:char))
+ (termp (* t))
+ (winp (* t))))
+
(defmacro define-eacces-test (name form &rest values)
#+win32 (declare (ignore name form values))
#-win32
@@ -710,6 +718,25 @@
(= new (sb-posix:cfgetospeed termios))))
t)
+(deftest tcsetattr.smoke.pty
+ (let (master-fd slave-fd)
+ (unwind-protect
+ (progn
+ (multiple-value-bind (rv master slave)
+ (openpty nil nil nil)
+ (assert (zerop rv))
+ (setf master-fd master
+ slave-fd slave))
+ (let ((termios (sb-posix:tcgetattr slave-fd)))
+ ;; The pre-fix bug on openBSD was that even round-tripping an
+ ;; unmodified termios value could smash memory or crash.
+ (sb-posix:tcsetattr slave-fd sb-posix:tcsanow termios))
+ t)
+ (when slave-fd
+ (sb-posix:close slave-fd))
+ (when master-fd
+ (sb-posix:close master-fd))))
+ t)
#-win32
(deftest time.1
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL