diff options
author | ache <ache@FreeBSD.org> | 1995-01-05 00:03:06 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1995-01-05 00:03:06 +0000 |
commit | a8479792d78867af62ffe3f93e9a4a0b7e12545a (patch) | |
tree | f7be989196355b5f991549d0d32ab500f8d35011 /sbin/comcontrol | |
parent | 7f9dfa2a43bd731a921618c72edad121f1854a1d (diff) | |
download | FreeBSD-src-a8479792d78867af62ffe3f93e9a4a0b7e12545a.zip FreeBSD-src-a8479792d78867af62ffe3f93e9a4a0b7e12545a.tar.gz |
Fight agaist hanging modems: add new drainwait option.
Reviewed by: Bruce
Diffstat (limited to 'sbin/comcontrol')
-rw-r--r-- | sbin/comcontrol/comcontrol.8 | 11 | ||||
-rw-r--r-- | sbin/comcontrol/comcontrol.c | 39 |
2 files changed, 38 insertions, 12 deletions
diff --git a/sbin/comcontrol/comcontrol.8 b/sbin/comcontrol/comcontrol.8 index 698d314..20bf4d5 100644 --- a/sbin/comcontrol/comcontrol.8 +++ b/sbin/comcontrol/comcontrol.8 @@ -24,6 +24,17 @@ Set the time to wait after dropping DTR to the given number. The units are hundredths of a second. The default is 300 hundredths, i.e., 3 seconds. +This option needed mainly to set proper recover time after +modem reset. +.El +.Bl -tag -width Fl +.It Cm drainwait Ar number +Set the time to wait for output drain +to the given number. +The units are seconds. +The default is 0, i.e. wait forever. +This option needed mainly to specify upper limit of minutes +to prevent modem hanging. .El .Pp The standard way to use diff --git a/sbin/comcontrol/comcontrol.c b/sbin/comcontrol/comcontrol.c index 40cf8d2..cb65f18 100644 --- a/sbin/comcontrol/comcontrol.c +++ b/sbin/comcontrol/comcontrol.c @@ -38,35 +38,38 @@ void usage(char *progname) { - fprintf(stderr, "usage: %s <filename> [dtrwait <n>]\n", progname); + fprintf(stderr, "usage: %s <filename> [dtrwait <n>] [drainwait <n>]\n", progname); exit(1); } int main(int argc, char *argv[]) { int fd; - int res; - int dtrwait; + int res = 0; + int dtrwait = -1, drainwait = -1; if ((argc < 2) || (argc > 5)) usage(argv[0]); fd = open(argv[1], O_RDONLY|O_NONBLOCK, 0); if (fd < 0) { - fprintf(stderr, "%s: couldn't open file %s\n", argv[0], argv[1]); perror("open"); - exit(1); + fprintf(stderr, "%s: couldn't open file %s\n", argv[0], argv[1]); + return 1; } if (argc == 2) { if (ioctl(fd, TIOCMGDTRWAIT, &dtrwait) < 0) { + res = 1; perror("TIOCMGDTRWAIT"); - exit(1); } - printf("dtrwait %d\n", dtrwait); + if (ioctl(fd, TIOCGDRAINWAIT, &drainwait) < 0) { + res = 1; + perror("TIOCGDRAINWAIT"); + } + printf("dtrwait %d drainwait %d\n", dtrwait, drainwait); } else { char *prg = argv[0]; - res = dtrwait = -1; while (argv[2] != NULL) { if (!strcmp(argv[2],"dtrwait")) { if (dtrwait >= 0) @@ -75,18 +78,30 @@ int main(int argc, char *argv[]) usage(prg); dtrwait = atoi(argv[3]); argv += 2; - } else { + } else if (!strcmp(argv[2],"drainwait")) { + if (drainwait >= 0) + usage(prg); + if (argv[3] == NULL || !isdigit(argv[3][0])) + usage(prg); + drainwait = atoi(argv[3]); + argv += 2; + } else usage(prg); - } } if (dtrwait >= 0) { if (ioctl(fd, TIOCMSDTRWAIT, &dtrwait) < 0) { + res = 1; perror("TIOCMSDTRWAIT"); - exit(1); + } + } + if (drainwait >= 0) { + if (ioctl(fd, TIOCSDRAINWAIT, &drainwait) < 0) { + res = 1; + perror("TIOCSDRAINWAIT"); } } } close(fd); - exit(0); + return res; } |