From 37c958a639fa0c9ed2cca7f3c505f9f644b3070e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 30 Dec 2015 23:07:22 +0100 Subject: m bug fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/unistd/daemonise.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/unistd') diff --git a/src/unistd/daemonise.c b/src/unistd/daemonise.c index 58cf848..90a9ca6 100644 --- a/src/unistd/daemonise.c +++ b/src/unistd/daemonise.c @@ -54,7 +54,7 @@ static char* __pidfile = NULL; */ static int dup_at_least_3(int old) { - int intermediary[] = { -1, -1, -1 }; + int intermediary[3]; int i = 0, saved_errno; do @@ -67,12 +67,12 @@ static int dup_at_least_3(int old) intermediary[i++] = old; } while (old < 3); + i--; fail: saved_errno = errno; - if (intermediary[0] >= 0) close(intermediary[0]); - if (intermediary[1] >= 0) close(intermediary[1]); - if (intermediary[2] >= 0) close(intermediary[2]); + while (i--) + close(intermediary[i]); errno = saved_errno; return old; } -- cgit v1.2.3-70-g09d2