summaryrefslogtreecommitdiff
path: root/tty.sh
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2014-04-28 02:46:50 +0200
committerAxel Beckert <abe@deuxchevaux.org>2014-04-28 02:46:50 +0200
commit285cd429f731082e1378c7e1362b083103c8a426 (patch)
tree90ce9c284c2812055530b6577591d725e125f75b /tty.sh
parentc3927cc39106d6b7cd746109784b6e8af203ec6b (diff)
downloadscreen-upstream.tar.gz
Imported Upstream version 4.2.1upstream/4.2.1upstream
Diffstat (limited to 'tty.sh')
-rw-r--r--tty.sh37
1 files changed, 27 insertions, 10 deletions
diff --git a/tty.sh b/tty.sh
index f2afd54..814f3d9 100644
--- a/tty.sh
+++ b/tty.sh
@@ -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
*/