Skip to content

Commit d9ba47c

Browse files
committed
Flatten TIOCGWINSZ on OpenBSD.
On this platform, the TIOCGWINSZ ioctl identifier is a complex macro. Since we don't have a C bridging header obviously available to get the flattened value, supply is the flattened value obtained elsewhere. This is of course brittle but this is the simplest way around this for now. Compare #291 in swift-argument-parser.
1 parent 21a7918 commit d9ba47c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/TSCBasic/TerminalController.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,13 @@ public final class TerminalController {
144144
// a temporary arrangement and needs to be fixed.
145145
#if !arch(powerpc64le)
146146
var ws = winsize()
147-
if ioctl(1, UInt(TIOCGWINSZ), &ws) == 0 {
147+
#if os(OpenBSD)
148+
let tiocgwinsz = 0x40087468
149+
let err = ioctl(1, UInt(tiocgwinsz), &ws)
150+
#else
151+
let err = ioctl(1, UInt(TIOCGWINSZ), &ws)
152+
#endif
153+
if err == 0 {
148154
return Int(ws.ws_col)
149155
}
150156
#endif

0 commit comments

Comments
 (0)