From 206bba4f2edfdbfc4ad5a382007d7ad6e0f67c0c Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 27 Jan 2021 02:50:28 +0000 Subject: [PATCH] pty.c: Restore build on systems without cfmakeraw(3) (re: 5a2e7dae) The OpenSUSE patch uses cfmakeraw(3) which is on Linux, BSD and macOS, but not portable. The build failed on Solaris and variants. src/cmd/builtin/features/pty: - Add simple test for the presence of cfmakeraw(3). I love iffe. src/cmd/builtin/pty.c: - Add POSIX compliant fallback flaggery for systems without it. --- src/cmd/builtin/features/pty | 1 + src/cmd/builtin/pty.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/cmd/builtin/features/pty b/src/cmd/builtin/features/pty index 31cfbbdc0..f912d3ead 100755 --- a/src/cmd/builtin/features/pty +++ b/src/cmd/builtin/features/pty @@ -11,6 +11,7 @@ header stropts.h lib openpty,_getpty,ptsname -lutil lib grantpt,unlockpt,posix_openpt stdlib.h +lib cfmakeraw termios.h tst - output{ #include diff --git a/src/cmd/builtin/pty.c b/src/cmd/builtin/pty.c index 72e586dcf..6dd94488e 100644 --- a/src/cmd/builtin/pty.c +++ b/src/cmd/builtin/pty.c @@ -236,7 +236,14 @@ mkpty(int* master, int* slave) { if (errno != ENOTTY) error(-1, "unable to get standard error terminal attributes"); +#if _lib_cfmakeraw cfmakeraw(&tty); +#else + tty.c_iflag |= IGNPAR; + tty.c_iflag &= ~(ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXANY | IXOFF); + tty.c_oflag &= ~OPOST; + tty.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE | ECHOK | ECHONL); +#endif /* _lib_cfmakeraw */ ttyp = 0; } tty.c_lflag |= ICANON | IEXTEN | ISIG | ECHO|ECHOE|ECHOK|ECHOKE;