From 2edebcbf9906093fdf088cfe790e6f9fe98ba4f2 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 6 Feb 2017 10:59:00 +0100 Subject: [PATCH] core: close GPIO chip device files on exec Pass the O_CLOEXEC flag to open() so that we don't leak open GPIO chip descriptors to any processes spawned by users of the library. Signed-off-by: Bartosz Golaszewski --- src/lib/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/core.c b/src/lib/core.c index 71ac7d2..f5beeb7 100644 --- a/src/lib/core.c +++ b/src/lib/core.c @@ -899,7 +899,7 @@ struct gpiod_chip * gpiod_chip_open(const char *path) struct gpiod_chip *chip; int status, fd; - fd = open(path, O_RDWR); + fd = open(path, O_RDWR | O_CLOEXEC); if (fd < 0) { last_error_from_errno(); return NULL; -- 2.30.2