diff --git a/scsh/tty1.c b/scsh/tty1.c index 10b857a..7cd7b60 100644 --- a/scsh/tty1.c +++ b/scsh/tty1.c @@ -11,11 +11,24 @@ * Re-written by Olin. */ +#include #include #include +#include + +/* This #include is for the #ifdef'd code in open_ctty() below, and +** is therefor ifdef'd identically. +*/ +#if defined(TIOCSCTTY) && !defined(CIBAUD) +#include +#endif #include "tty1.h" /* Make sure the .h interface agrees with the code. */ +extern int errno; + +/*****************************************************************************/ + int scheme_tcgetattr(int fd, char *control_chars, int *iflag_hi8, int *iflag_lo24, int *oflag_hi8, int *oflag_lo24, @@ -40,6 +53,8 @@ int scheme_tcgetattr(int fd, char *control_chars, } +/*****************************************************************************/ + int scheme_tcsetattr(int fd, int option, const char *control_chars, int iflag_hi8, int iflag_lo24, @@ -75,3 +90,28 @@ int scheme_tcsetattr(int fd, int option, return tcsetattr(fd, option, &t); } + + +/*****************************************************************************/ + +int open_ctty(const char *ttyname, int flags) +{ + int fd = open(ttyname, flags); + +/* The ifdef is tricked by HP-UX, so I'll hardwire it out for now. -Olin */ +#if 0 +#if defined(TIOCSCTTY) && !defined(CIBAUD) + fprintf(stderr, "Doing the ioctl.\n"); + /* 4.3+BSD way to acquire control tty. !CIBAUD rules out SunOS. + ** This code stolen from Steven's *Advanced Prog. in the Unix Env.* + */ + if( (fd >= 0) && (ioctl(fd, TIOCSCTTY, (char *) 0) < 0) ) { + int e = errno; + close(fd); + errno = e; + return -1; + } +#endif +#endif + return fd; + } diff --git a/scsh/tty1.h b/scsh/tty1.h index 3ad12ba..717b4e4 100644 --- a/scsh/tty1.h +++ b/scsh/tty1.h @@ -15,3 +15,5 @@ int scheme_tcsetattr(int fd, int option, int lflag_hi8, int lflag_lo24, int ispeed, int ospeed, int min, int time); + +int open_ctty(const char *ttyname, int flags);