X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Futils.c;h=7d4834fba4e42bc93549d6fe2aec8e04f6a13ca1;hb=3382df979cd96e15fd77f7c0ba95c39610c93272;hp=634e41ffec0b3b296be0c039957cebd79c84cc03;hpb=179dacd7350cef30f0de730cc54647baaf95a6c3;p=wget diff --git a/src/utils.c b/src/utils.c index 634e41ff..7d4834fb 100644 --- a/src/utils.c +++ b/src/utils.c @@ -51,8 +51,7 @@ as that of the covered work. */ #include #include -#include - +#include /* For TIOCGWINSZ and friends: */ #ifdef HAVE_SYS_IOCTL_H @@ -488,15 +487,25 @@ fork_to_background (void) void touch (const char *file, time_t tm) { - struct timeval timevals[2]; + struct timespec timespecs[2]; + int fd; - timevals[0].tv_sec = time (NULL); - timevals[0].tv_usec = 0L; - timevals[1].tv_sec = tm; - timevals[1].tv_usec = 0L; + fd = open (file, O_WRONLY); + if (fd < 0) + { + logprintf (LOG_NOTQUIET, "open(%s): %s\n", file, strerror (errno)); + return; + } - if (utimes (file, timevals) == -1) - logprintf (LOG_NOTQUIET, "utimes(%s): %s\n", file, strerror (errno)); + timespecs[0].tv_sec = time (NULL); + timespecs[0].tv_nsec = 0L; + timespecs[1].tv_sec = tm; + timespecs[1].tv_nsec = 0L; + + if (futimens (fd, timespecs) == -1) + logprintf (LOG_NOTQUIET, "futimens(%s): %s\n", file, strerror (errno)); + + close (fd); } /* Checks if FILE is a symbolic link, and removes it if it is. Does @@ -866,6 +875,9 @@ acceptable (const char *s) { int l = strlen (s); + if (opt.output_document && strcmp (s, opt.output_document) == 0) + return true; + while (l && s[l] != '/') --l; if (s[l] == '/') @@ -1918,9 +1930,10 @@ abort_run_with_timeout (int sig) /* We don't have siglongjmp to preserve the set of blocked signals; if we longjumped out of the handler at this point, SIGALRM would remain blocked. We must unblock it manually. */ - int mask = siggetmask (); - mask &= ~sigmask (SIGALRM); - sigsetmask (mask); + sigset_t set; + sigemptyset (&set); + sigaddset (&set, SIGALRM); + sigprocmask (SIG_BLOCK, &set, NULL); /* Now it's safe to longjump. */ longjmp (run_with_timeout_env, -1);