From 2da59394ec858ae5aecf2b26ab8d9fefdae17bb8 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 8 Nov 2016 20:46:05 +0100 Subject: lib: add and use set_cloexec() watchquagga is already leaking an open file descriptor on its pid file on fork+exec() invocations; next up is adding vtysh support with even more fds. Mark things CLOEXEC before going there. Signed-off-by: David Lamparter --- lib/pid_output.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/pid_output.c') diff --git a/lib/pid_output.c b/lib/pid_output.c index 5261babc6d..de4c2fba99 100644 --- a/lib/pid_output.c +++ b/lib/pid_output.c @@ -24,6 +24,7 @@ #include #include #include "version.h" +#include "network.h" #define PIDFILE_MASK 0644 #ifndef HAVE_FCNTL @@ -84,6 +85,8 @@ pid_output (const char *path) umask(oldumask); memset (&lock, 0, sizeof(lock)); + set_cloexec(fd); + lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; -- cgit v1.2.3