summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2014-08-20 20:49:30 -0500
committerNicolas Williams <nico@cryptonector.com>2014-08-20 20:49:30 -0500
commit23e2e2eab3e09cd651295b361cfac4f03be0dd53 (patch)
treeaae464e3f20fe5317ebc10a477157ee40d9fc239
parent8d2d5e37e54ecfa823f0a5c6e9644aa2e97d5ee6 (diff)
Quiet warning about freopen() of stdout
-rw-r--r--main.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/main.c b/main.c
index 089409fa..32db92c9 100644
--- a/main.c
+++ b/main.c
@@ -479,13 +479,18 @@ int main(int argc, char* argv[]) {
}
}
if ((options & IN_PLACE)) {
+ FILE *devnull;
#ifdef WIN32
- (void) freopen("NUL", "w+", stdout);
+ devnull = freopen("NUL", "w+", stdout);
#else
- (void) freopen("/dev/null", "w+", stdout);
+ devnull = freopen("/dev/null", "w+", stdout);
#endif
+ if (devnull == NULL) {
+ fprintf(stderr, "Error: %s opening /dev/null\n", strerror(errno));
+ exit(3);
+ }
if (rename(t, input_filenames[0]) == -1) {
- fprintf(stderr, "Error: %s renaming temporary file", strerror(errno));
+ fprintf(stderr, "Error: %s renaming temporary file\n", strerror(errno));
exit(3);
}
jv_mem_free(t);