From 7b161df218c48c8ca86e9e1c402d7ba84a951ffc Mon Sep 17 00:00:00 2001 From: jkh Date: Sat, 22 Jun 1996 20:16:57 +0000 Subject: Address Andrey's complaints: 1. Always use file modtime, and if that's not usable then default to current time. 2. Allow HTTP_TIMEOUT to be set as an environment variable to override default. 3. Handle SIGTERM. --- usr.bin/fetch/main.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/fetch/main.c b/usr.bin/fetch/main.c index 470f617..45dfccd 100644 --- a/usr.bin/fetch/main.c +++ b/usr.bin/fetch/main.c @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: main.c,v 1.1.1.1 1996/06/19 09:32:11 asami Exp $ */ #include #include @@ -137,6 +137,7 @@ main (int argc, char **argv) signal (SIGHUP, die); signal (SIGINT, die); signal (SIGQUIT, die); + signal (SIGTERM, die); if (http) httpget (); @@ -186,12 +187,11 @@ ftpget () if (size < 0) ftperr (ftp, "%s: ", file_to_get); - if (restart) { - modtime = ftpGetModtime (ftp, file_to_get); - if (modtime < -1) - err (1, "Unrecoverable error (ftpGetModtime)"); - } else + modtime = ftpGetModtime (ftp, file_to_get); + if (modtime < -1) { + warnx ("Couldn't get file time for %s - using current time", file_to_get); modtime = (time_t) -1; + } if (!strcmp (outputfile, "-")) restart = 0; @@ -403,7 +403,7 @@ ftperr (FILE* ftp, char *fmt, ...) void httpget () { - char str[1000]; + char *cp, str[1000]; struct timeval tout; fd_set fdset; int i, s; @@ -418,7 +418,10 @@ httpget () FD_ZERO (&fdset); FD_SET (s, &fdset); - tout.tv_sec = HTTP_TIMEOUT; + if ((cp = getenv("HTTP_TIMEOUT")) != NULL) + tout.tv_sec = atoi(cp); + else + tout.tv_sec = HTTP_TIMEOUT; tout.tv_usec = 0; if (strcmp (outputfile, "-")) { -- cgit v1.1