+ /*
+ * The following is a work around for vhangup interactions
+ * which cause great problems getting window systems started.
+ * If the tty line is "-", we do the old style getty presuming
+ * that the file descriptors are already set up for us.
+ * J. Gettys - MIT Project Athena.
+ */
+ if (argc <= 2 || strcmp(argv[2], "-") == 0)
+ strcpy(ttyn, ttyname(0));
+ else {
+ strcpy(ttyn, dev);
+ strncat(ttyn, argv[2], sizeof(ttyn)-sizeof(dev));
+ if (strcmp(argv[0], "+") != 0) {
+ chown(ttyn, 0, 0);
+ chmod(ttyn, 0622);
+ /*
+ * Delay the open so DTR stays down long enough to be detected.
+ */
+ sleep(2);
+ while (open(ttyn, O_RDWR) != 0) {
+ if (repcnt % 10 == 0) {
+ syslog(LOG_ERR, "%s: %m", ttyn);
+ closelog();
+ }
+ repcnt++;
+ sleep(60);
+ }
+ signal(SIGHUP, SIG_IGN);
+ vhangup();
+ (void) open(ttyn, O_RDWR);
+ close(0);
+ dup(1);
+ dup(0);
+ signal(SIGHUP, SIG_DFL);
+ }
+ }
+