mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-15 23:36:59 +00:00
print include system error message when output fails
Users want to know why write fail - was it because disk full, or destination read-only, or IO error, and so on. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
f5cd7383e4
commit
8fca82f148
2 changed files with 13 additions and 13 deletions
|
|
@ -405,7 +405,7 @@ void clean_up(void)
|
|||
|
||||
/* Just in case there something in buffers */
|
||||
if (fflush(NULL))
|
||||
error(0, 0, "clean_up: fflush");
|
||||
error(EXIT_FAILURE, errno, "clean_up: fflush");
|
||||
free(config.dhcpdconf_file);
|
||||
free(config.dhcpdlease_file);
|
||||
free(config.output_file);
|
||||
|
|
|
|||
24
src/output.c
24
src/output.c
|
|
@ -200,12 +200,12 @@ int output_txt(void)
|
|||
if (outfile == stdout) {
|
||||
ret = fflush(stdout);
|
||||
if (ret) {
|
||||
error(0, 0, "output_txt: fflush");
|
||||
error(EXIT_FAILURE, errno, "output_txt: fflush");
|
||||
}
|
||||
} else {
|
||||
ret = close_stream(outfile);
|
||||
if (ret) {
|
||||
error(0, 0, "output_txt: fclose");
|
||||
error(EXIT_FAILURE, errno, "output_txt: fclose");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -303,12 +303,12 @@ int output_xml(void)
|
|||
if (outfile == stdout) {
|
||||
ret = fflush(stdout);
|
||||
if (ret) {
|
||||
error(0, 0, "output_xml: fflush");
|
||||
error(EXIT_FAILURE, errno, "output_xml: fflush");
|
||||
}
|
||||
} else {
|
||||
ret = close_stream(outfile);
|
||||
if (ret) {
|
||||
error(0, 0, "output_xml: fclose");
|
||||
error(EXIT_FAILURE, errno, "output_xml: fclose");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -440,12 +440,12 @@ int output_json(void)
|
|||
if (outfile == stdout) {
|
||||
ret = fflush(stdout);
|
||||
if (ret) {
|
||||
error(0, 0, "output_json: fflush");
|
||||
error(EXIT_FAILURE, errno, "output_json: fflush");
|
||||
}
|
||||
} else {
|
||||
ret = close_stream(outfile);
|
||||
if (ret) {
|
||||
error(0, 0, "output_json: fclose");
|
||||
error(EXIT_FAILURE, errno, "output_json: fclose");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -769,12 +769,12 @@ int output_html(void)
|
|||
if (outfile == stdout) {
|
||||
ret = fflush(stdout);
|
||||
if (ret) {
|
||||
error(0, 0, "output_html: fflush");
|
||||
error(EXIT_FAILURE, errno, "output_html: fflush");
|
||||
}
|
||||
} else {
|
||||
ret = close_stream(outfile);
|
||||
if (ret) {
|
||||
error(0, 0, "output_html: fclose");
|
||||
error(EXIT_FAILURE, errno, "output_html: fclose");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -911,12 +911,12 @@ int output_csv(void)
|
|||
if (outfile == stdout) {
|
||||
ret = fflush(stdout);
|
||||
if (ret) {
|
||||
error(0, 0, "output_cvs: fflush");
|
||||
error(EXIT_FAILURE, errno, "output_cvs: fflush");
|
||||
}
|
||||
} else {
|
||||
ret = close_stream(outfile);
|
||||
if (ret) {
|
||||
error(0, 0, "output_cvs: fclose");
|
||||
error(EXIT_FAILURE, errno, "output_cvs: fclose");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1032,12 +1032,12 @@ int output_alarming(void)
|
|||
if (outfile == stdout) {
|
||||
ret = fflush(stdout);
|
||||
if (ret) {
|
||||
error(0, 0, "output_alarming: fflush");
|
||||
error(EXIT_FAILURE, errno, "output_alarming: fflush");
|
||||
}
|
||||
} else {
|
||||
ret = close_stream(outfile);
|
||||
if (ret) {
|
||||
error(0, 0, "output_alarming: fclose");
|
||||
error(EXIT_FAILURE, errno, "output_alarming: fclose");
|
||||
}
|
||||
}
|
||||
return ret_val;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue