w3mail

program to send a web page by email
git clone https://logand.com/git/w3mail.git/
Log | Files | Refs | README | LICENSE

commit a6555720bd5a325452c152dcd6028dd89619102d
parent fad7b23c17ece19cc9967cad9b8f83a191344da7
Author: Tomas Hlavaty <tom@logand.com>
Date:   Fri, 28 Jan 2011 02:05:59 +0100

wget status fix

Diffstat:
Mutils.c | 25+++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/utils.c b/utils.c @@ -119,23 +119,24 @@ void wget(char *url, char *fname) { if(pid < 0) die(pid, "wget(): fork failed"); else if(pid == 0) execlp("wget", "wget", "-q", "-O", fname, "--", url, NULL); else { - int status; + int x; do { - pid_t w = waitpid(pid, &status, WUNTRACED | WCONTINUED); + pid_t w = waitpid(pid, &x, WUNTRACED | WCONTINUED); if(w == -1) die(1, "wget(): waitpid failed on wget '%s'", url); - if(WIFEXITED(status) && WEXITSTATUS(status)) { - int n = WEXITSTATUS(status); - fprintf(stderr, "wget '%s' failed with status %d: %s\n", url, - n, (0 <= n && n <= 8) ? wgetmsg[n] : "unexpected status"); + if(WIFEXITED(x)) { + int n = WEXITSTATUS(x); + if(n) + fprintf(stderr, "wget '%s' failed with status %d: %s\n", url, + n, (0 <= n && n <= 8) ? wgetmsg[n] : "unexpected status"); } - else if(WIFSIGNALED(status)) + else if(WIFSIGNALED(x)) fprintf(stderr, "wget '%s' killed by signal %d\n", url, - WTERMSIG(status)); - else if(WIFSTOPPED(status)) + WTERMSIG(x)); + else if(WIFSTOPPED(x)) fprintf(stderr, "wget '%s' stopped by signal %d\n", url, - WSTOPSIG(status)); - else if(WIFCONTINUED(status)) + WSTOPSIG(x)); + else if(WIFCONTINUED(x)) fprintf(stderr, "wget '%s' continued\n", url); - } while(!WIFEXITED(status) && !WIFSIGNALED(status)); + } while(!WIFEXITED(x) && !WIFSIGNALED(x)); } }