*/
#ifndef lint
-static char rcsid[] = "$Id: sys-svr4.c,v 1.3 1995/06/23 01:54:11 paulus Exp $";
+static char rcsid[] = "$Id: sys-svr4.c,v 1.5 1995/08/11 02:36:24 paulus Exp $";
#endif
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
+#include <signal.h>
#include <sys/types.h>
#include <sys/ioccom.h>
#include <sys/stream.h>
static int restore_term;
static struct termios inittermios;
+static struct winsize wsinfo; /* Initial window size info */
+static pid_t tty_sid; /* original session ID for terminal */
static int link_mtu, link_mru;
{
int i, ifd;
+ if (default_device)
+ tty_sid = getsid((pid_t)0);
+
pppfd = open("/dev/ppp", O_RDWR | O_NONBLOCK, 0);
if (pppfd < 0) {
syslog(LOG_ERR, "Can't open /dev/ppp: %m");
syslog(LOG_ERR, "Couldn't restore tty module %s: %m",
tty_modules[i]);
}
+ if (hungup && default_device && tty_sid > 0) {
+ /*
+ * If we have received a hangup, we need to send a SIGHUP
+ * to the terminal's controlling process. The reason is
+ * that the original stream head for the terminal hasn't
+ * seen the M_HANGUP message (it went up through the ppp
+ * driver to the stream head for our fd to /dev/ppp).
+ */
+ kill(tty_sid, SIGHUP);
+ }
}
}
die(1);
}
- if (!restore_term)
+ if (!restore_term) {
inittermios = tios;
+ ioctl(fd, TIOCGWINSZ, &wsinfo);
+ }
tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | CLOCAL);
if (crtscts > 0)
if (tcsetattr(fd, TCSAFLUSH, &inittermios) < 0)
if (!hungup && errno != ENXIO)
syslog(LOG_WARNING, "tcsetattr: %m");
+ ioctl(fd, TIOCSWINSZ, &wsinfo);
restore_term = 0;
}
}
syslog(LOG_ERR, "sysinfo: %m");
return 0;
}
- return strtol(buf, NULL, 16);
+ return (int) strtoul(buf, NULL, 16);
}
int