diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2014-04-28 02:46:50 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2014-04-28 02:46:50 +0200 |
commit | 285cd429f731082e1378c7e1362b083103c8a426 (patch) | |
tree | 90ce9c284c2812055530b6577591d725e125f75b /tty.sh | |
parent | c3927cc39106d6b7cd746109784b6e8af203ec6b (diff) | |
download | screen-upstream.tar.gz |
Imported Upstream version 4.2.1upstream/4.2.1upstream
Diffstat (limited to 'tty.sh')
-rw-r--r-- | tty.sh | 37 |
1 files changed, 27 insertions, 10 deletions
@@ -60,6 +60,7 @@ exit 0 #include <sys/types.h> #include <signal.h> #include <fcntl.h> +#include <sys/stat.h> #ifndef sgi # include <sys/file.h> #endif @@ -808,18 +809,11 @@ int fd; mypid = getpid(); - /* The next lines should be obsolete. Can anybody check if they - * are really needed on the BSD platforms? - * - * this is to avoid the message: - * fgtty: Not a typewriter (25) + /* + * Under BSD we have to set the controlling terminal again explicitly. */ -# if defined(__osf__) || (BSD >= 199103) || defined(ISC) - if (separate_sids) - setsid(); /* should be already done */ -# ifdef TIOCSCTTY +# if (defined(__FreeBSD_kernel__) || defined(__GNU__)) && defined(TIOCSCTTY) ioctl(fd, TIOCSCTTY, (char *)0); -# endif # endif # ifdef POSIX @@ -1506,6 +1500,29 @@ int ibaud, obaud; return 0; } + +int +CheckTtyname (tty) +char *tty; +{ + struct stat st; + char * real; + int rc; + + real = realpath(tty, NULL); + if (!real) + return -1; + + if (lstat(real, &st) || !S_ISCHR(st.st_mode) || + (st.st_nlink > 1 && strncmp(real, "/dev/", 5))) + rc = -1; + else + rc = 0; + + free(real); + return rc; +} + /* * Write out the mode struct in a readable form */ |