summaryrefslogtreecommitdiff
path: root/tty.sh
diff options
context:
space:
mode:
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
*/