From: Giuseppe Scrivano Date: Sun, 17 Jun 2012 20:24:32 +0000 (+0200) Subject: Check for fclose errors. X-Git-Tag: v1.14~8 X-Git-Url: http://sjero.net/git/?p=wget;a=commitdiff_plain;h=ae0598df9bc459652c167fa9826a72b10b775a7a Check for fclose errors. --- diff --git a/src/ChangeLog b/src/ChangeLog index b3937051..7b2bde0e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-06-17 Giuseppe Scrivano + + * wget.h: Define `CLOSEFAILED'. + * init.c: Include "exits.h". + (cleanup): Check `fclose' failure. + * exits.c (get_status_for_err): Handle `CLOSEFAILED'. + 2012-06-16 Giuseppe Scrivano * main.c (main): Move some cleanup related function to... diff --git a/src/exits.c b/src/exits.c index 3d846b56..2233cdc1 100644 --- a/src/exits.c +++ b/src/exits.c @@ -60,7 +60,7 @@ get_status_for_err (uerr_t err) case RETROK: return WGET_EXIT_SUCCESS; case FOPENERR: case FOPEN_EXCL_ERR: case FWRITEERR: case WRITEFAILED: - case UNLINKERR: + case UNLINKERR: case CLOSEFAILED: return WGET_EXIT_IO_FAIL; case NOCONERROR: case HOSTERR: case CONSOCKERR: case CONERROR: case CONSSLERR: case CONIMPOSSIBLE: case FTPRERR: case FTPINVPASV: diff --git a/src/init.c b/src/init.c index 40b62b27..4188ca16 100644 --- a/src/init.c +++ b/src/init.c @@ -30,6 +30,7 @@ shall include the source code for the parts of OpenSSL used as well as that of the covered work. */ #include "wget.h" +#include "exits.h" #include #include @@ -1682,7 +1683,9 @@ cleanup (void) log_close (); if (output_stream) - fclose (output_stream); + if (fclose (output_stream) == EOF) + inform_exit_status (CLOSEFAILED); + /* No need to check for error because Wget flushes its output (and checks for errors) after any data arrives. */ diff --git a/src/wget.h b/src/wget.h index ee315b6f..ca4a702d 100644 --- a/src/wget.h +++ b/src/wget.h @@ -353,7 +353,7 @@ typedef enum PROXERR, /* 50 */ AUTHFAILED, QUOTEXC, WRITEFAILED, SSLINITFAILED, VERIFCERTERR, - UNLINKERR, NEWLOCATION_KEEP_POST, + UNLINKERR, NEWLOCATION_KEEP_POST, CLOSEFAILED, WARC_ERR, WARC_TMP_FOPENERR, WARC_TMP_FWRITEERR } uerr_t;