From: Jonathan McDowell Date: Fri, 17 Dec 2004 10:17:14 +0000 (+0000) Subject: Fix problem with closing stderr in add.c X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/e18b268d5c83bc3ad5d8cec975fa3adbf96ba2ae?hp=39b352321e40d267678d02d13ab6de1e1e4958c6 Fix problem with closing stderr in add.c Fred Strauss reported a problem when we close stderr in add.c; we now do some basic checking to try to ensure it's a valid file ptr before we close it. Also do this for stdout just in case. --- diff --git a/add.c b/add.c index 10627f2..167e5bd 100644 --- a/add.c +++ b/add.c @@ -68,8 +68,13 @@ int main(int argc, char *argv[]) count); printf("Storing %d keys.\n", count); end_html(); - fclose(stdout); - fclose(stderr); + if (stdout != NULL && fileno(stdout) != -1) { + fclose(stdout); + } + if (stderr != NULL && stderr != stdout && + fileno(stderr) != -1) { + fclose(stderr); + } catchsignals(); initdb(false);