From b97593a2d7599dfb1d815e8ff20332a3a65b650f Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 4 May 2014 20:41:22 +0200 Subject: [PATCH] example: only close output fd after request completion if -O was not used Signed-off-by: Felix Fietkau --- uclient-example.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/uclient-example.c b/uclient-example.c index 144696c..5e478c3 100644 --- a/uclient-example.c +++ b/uclient-example.c @@ -86,7 +86,7 @@ static int open_output_file(const char *path, bool create) static void request_done(struct uclient *cl) { - if (output_fd >= 0) { + if (output_fd >= 0 && !output_file) { close(output_fd); output_fd = -1; } @@ -327,6 +327,9 @@ int main(int argc, char **argv) uclient_free(cl); + if (output_fd >= 0 && output_fd != STDOUT_FILENO) + close(output_fd); + if (ssl_ctx) ssl_ops->context_free(ssl_ctx); -- 2.25.1