aboutsummaryrefslogtreecommitdiff
path: root/sbin/comcontrol
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1995-01-05 00:03:06 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1995-01-05 00:03:06 +0000
commitb0e399e3c44a7791ef48b094c79f2a145cb9ed53 (patch)
treef7be989196355b5f991549d0d32ab500f8d35011 /sbin/comcontrol
parent33c38bd57424b5403e3c312a6c1f0bcc2e6c5c2b (diff)
downloadsrc-b0e399e3c44a7791ef48b094c79f2a145cb9ed53.tar.gz
src-b0e399e3c44a7791ef48b094c79f2a145cb9ed53.zip
Fight agaist hanging modems: add new drainwait option.
Reviewed by: Bruce
Notes
Notes: svn path=/head/; revision=5397
Diffstat (limited to 'sbin/comcontrol')
-rw-r--r--sbin/comcontrol/comcontrol.811
-rw-r--r--sbin/comcontrol/comcontrol.c39
2 files changed, 38 insertions, 12 deletions
diff --git a/sbin/comcontrol/comcontrol.8 b/sbin/comcontrol/comcontrol.8
index 698d314d26a9..20bf4d5d026f 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 40cf8d25c8a8..cb65f18990a7 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;
}