Made gotty a bit more robust

Now gotty does not exit on errors but simply tries to reconnect.
This commit is contained in:
Martin Lund 2014-09-27 19:10:32 +02:00
parent df8652f05d
commit 38935dc0f5

View file

@ -110,10 +110,7 @@ int connect_tty(void)
/* Save current port settings */ /* Save current port settings */
if (tcgetattr(fd, &old_tio) < 0) if (tcgetattr(fd, &old_tio) < 0)
{ return EXIT_FAILURE;
printf("Error: Saving current port settings failed\n");
exit(EXIT_FAILURE);
}
/* Make sure we restore settings on exit */ /* Make sure we restore settings on exit */
if (first) if (first)
@ -158,7 +155,8 @@ int connect_tty(void)
{ {
if (!option.no_autoconnect) if (!option.no_autoconnect)
gotty_printf("Disconnected"); gotty_printf("Disconnected");
return(EXIT_FAILURE); close(fd);
return EXIT_FAILURE;
} }
} }
if (FD_ISSET(console, &rdfs)) if (FD_ISSET(console, &rdfs))
@ -170,12 +168,15 @@ int connect_tty(void)
c1 = c0; c1 = c0;
c0 = c; c0 = c;
if ((c0 == CTRLQ) && (c1 == CTRLG)) if ((c0 == CTRLQ) && (c1 == CTRLG))
{
close(fd);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
}
/* Forward input to tty device */ /* Forward input to tty device */
status = write(fd, &c, 1); status = write(fd, &c, 1);
} }
} }
return(EXIT_SUCCESS); return EXIT_SUCCESS;
} }