From 891559e499c0d2d1d6203ec3540ff759160338f3 Mon Sep 17 00:00:00 2001 From: oshogbo Date: Mon, 13 Jun 2016 00:03:55 +0000 Subject: [PATCH] Don't close fd if it's lower then stderr, otherwise we can close one of the descriptor which we just set. Pointed out by: jilles Approved by: re (hrs) --- lib/libcasper/libcasper/service.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/libcasper/libcasper/service.c b/lib/libcasper/libcasper/service.c index 52318121cbb0..cc53d0d630ae 100644 --- a/lib/libcasper/libcasper/service.c +++ b/lib/libcasper/libcasper/service.c @@ -360,7 +360,8 @@ stdnull(void) if (dup2(fd, STDERR_FILENO) == -1) errx(1, "Unable to cover stderr"); - close(fd); + if (fd > STDERR_FILENO) + close(fd); } static void