summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1996-06-22 20:16:57 +0000
committerjkh <jkh@FreeBSD.org>1996-06-22 20:16:57 +0000
commit7b161df218c48c8ca86e9e1c402d7ba84a951ffc (patch)
tree921f998dc0e0744b5bd58e3a211ce2f30835b01a /usr.bin
parent8c1de2763b887a4b942724ccad9e581093b60440 (diff)
downloadFreeBSD-src-7b161df218c48c8ca86e9e1c402d7ba84a951ffc.zip
FreeBSD-src-7b161df218c48c8ca86e9e1c402d7ba84a951ffc.tar.gz
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.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/fetch/main.c19
1 files changed, 11 insertions, 8 deletions
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 <stdlib.h>
#include <stdio.h>
@@ -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, "-")) {
OpenPOWER on IntegriCloud