From: Bartosz Golaszewski Date: Mon, 6 Feb 2017 09:59:00 +0000 (+0100) Subject: core: close GPIO chip device files on exec X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2edebcbf9906093fdf088cfe790e6f9fe98ba4f2;p=qemu-gpiodev%2Flibgpiod.git 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 --- 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;