From: Felix Fietkau Date: Sun, 4 May 2014 18:41:22 +0000 (+0200) Subject: example: only close output fd after request completion if -O was not used X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fuclient.git;a=commitdiff_plain;h=b97593a2d7599dfb1d815e8ff20332a3a65b650f example: only close output fd after request completion if -O was not used Signed-off-by: Felix Fietkau --- 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);