From a2467ea894b37b0861b92e35edd93788f8e2a342 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Fri, 1 Dec 2023 00:00:27 +0800 Subject: fdset: set all collected fds to CLOEXEC in fdset_new_fill() --- src/test/test-fdset.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/test-fdset.c b/src/test/test-fdset.c index 8947a319b6..8f00e598fd 100644 --- a/src/test/test-fdset.c +++ b/src/test/test-fdset.c @@ -11,8 +11,8 @@ #include "tmpfile-util.h" TEST(fdset_new_fill) { - int fd = -EBADF; _cleanup_fdset_free_ FDSet *fdset = NULL; + int fd = -EBADF, flags; log_close(); log_set_open_when_needed(true); @@ -50,6 +50,9 @@ TEST(fdset_new_fill) { assert_se(fdset_new_fill(/* filter_cloexec= */ 0, &fdset) >= 0); assert_se(fdset_contains(fdset, fd)); + flags = fcntl(fd, F_GETFD); + assert_se(flags >= 0); + assert_se(FLAGS_SET(flags, FD_CLOEXEC)); fdset = fdset_free(fdset); assert_se(fcntl(fd, F_GETFD) < 0); assert_se(errno == EBADF); -- cgit v1.2.3