From 59cf368df43679eda9fd58751cea358749aa05fc Mon Sep 17 00:00:00 2001 From: Mariusz Zaborski 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 52318121cbb..cc53d0d630a 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