diff options
Diffstat (limited to 'lib/libss')
-rw-r--r-- | lib/libss/listen.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/libss/listen.c b/lib/libss/listen.c index 8420ad7..351129c 100644 --- a/lib/libss/listen.c +++ b/lib/libss/listen.c @@ -1,3 +1,5 @@ + + /* * Listener loop for subsystem library libss.a. * @@ -15,9 +17,12 @@ #include <setjmp.h> #include <signal.h> #include <sys/param.h> -#ifdef BSD +#if defined(BSD) && !defined(POSIX) #include <sgtty.h> #endif +#ifdef POSIX +#include <termios.h> +#endif #ifndef lint static char const rcs_id[] = @@ -37,14 +42,23 @@ static jmp_buf listen_jmpb; static sigtype print_prompt() { -#ifdef BSD /* put input into a reasonable mode */ +#if defined(BSD) && !defined(POSIX) struct sgttyb ttyb; if (ioctl(fileno(stdin), TIOCGETP, &ttyb) != -1) { if (ttyb.sg_flags & (CBREAK|RAW)) { ttyb.sg_flags &= ~(CBREAK|RAW); (void) ioctl(0, TIOCSETP, &ttyb); } +#endif +#ifdef POSIX + struct termios tio; + if (tcgetattr(fileno(stdin), &tio) != -1) { + tio.c_oflag |= (OPOST|ONLCR); + tio.c_iflag &= ~(IGNCR|INLCR); + tio.c_iflag |= (ICRNL); + tio.c_lflag |= (ICANON); + (void) tcsetattr(0, TCSADRAIN, &tio); } #endif (void) fputs(current_info->prompt, stdout); |