From ec511f82926483f27ceebf3f100517176b1ce95d Mon Sep 17 00:00:00 2001 From: ache Date: Fri, 15 Sep 1995 17:30:03 +0000 Subject: Restore TTYDISC on exit. Move setting of control terminal after TTYDISC setting --- sbin/startslip/startslip.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'sbin/startslip/startslip.c') diff --git a/sbin/startslip/startslip.c b/sbin/startslip/startslip.c index 2ec15d8..587734a 100644 --- a/sbin/startslip/startslip.c +++ b/sbin/startslip/startslip.c @@ -87,8 +87,9 @@ int script_timeout = 90; /* connect script default timeout */ char *dials[MAXDIALS]; int diali, dialc; +int fd = -1; FILE *pfd; -char *devname; +char *devname, *devicename; char pidfile[80]; #ifdef DEBUG @@ -111,13 +112,12 @@ main(argc, argv) extern int optind; char *cp, **ap; int ch, disc; - int fd = -1; void sighup(), sigterm(); FILE *wfd = NULL; char *dialerstring = 0, buf[BUFSIZ]; int unitnum; char unitname[32]; - char *devicename, *username, *password; + char *username, *password; char *upscript = NULL, *downscript = NULL; int first = 1, tries = 0; int pausefirst = 0; @@ -307,12 +307,6 @@ restart: } } printd(" %d", fd); -#ifdef TIOCSCTTY - if (ioctl(fd, TIOCSCTTY, 0) < 0) { - syslog(LOG_ERR, "ioctl (TIOCSCTTY): %m"); - down(2); - } -#endif signal(SIGHUP, sighup); signal(SIGTERM, sigterm); if (debug) { @@ -327,6 +321,12 @@ restart: devicename); down(2); } +#ifdef TIOCSCTTY + if (ioctl(fd, TIOCSCTTY, 0) < 0) { + syslog(LOG_ERR, "ioctl (TIOCSCTTY): %m"); + down(2); + } +#endif printd(", ioctl"); #ifdef POSIX if (tcgetattr(fd, &t) < 0) { @@ -541,6 +541,11 @@ getline(buf, size, fd, timeout) down(code) { + int disc = TTYDISC; + + if (fd > -1 && ioctl(fd, TIOCSETD, &disc) < 0) + syslog(LOG_ERR, "%s: ioctl (TIOCSETD 0): %m", + devicename); if (pfd) unlink(pidfile); if (locked) -- cgit v1.1