Skip to content

Commit

Permalink
pty.c: Restore build on systems without cfmakeraw(3) (re: 5a2e7da)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
McDutchie committed Jan 27, 2021
1 parent 8e45dae commit 206bba4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/cmd/builtin/features/pty
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/types.h>
Expand Down
7 changes: 7 additions & 0 deletions src/cmd/builtin/pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 206bba4

Please sign in to comment.