diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-09 05:56:36 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-05-09 05:56:36 +0000 |
commit | 2f355745ea98538834cd2e9fc766469169144f47 (patch) | |
tree | 0425e2528abca3f7f9af7b664013837d0dd37320 /libc/bionic | |
parent | 41bfc884f62086b071ea424d6c0675fb1481afe3 (diff) | |
parent | bbe7c690f1fbe714fe06c2107cb3e4d25bc791f2 (diff) | |
download | bionic-android13-frc-art-release.tar.gz |
Snap for 8558685 from bbe7c690f1fbe714fe06c2107cb3e4d25bc791f2 to tm-frc-art-releaset_frc_art_330443060android13-frc-art-release
Change-Id: I914023a34993bdfe6d6f0314fd322da58fba8813
Diffstat (limited to 'libc/bionic')
-rw-r--r-- | libc/bionic/spawn.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libc/bionic/spawn.cpp b/libc/bionic/spawn.cpp index 314a05669..59f763138 100644 --- a/libc/bionic/spawn.cpp +++ b/libc/bionic/spawn.cpp @@ -30,10 +30,12 @@ #include <errno.h> #include <fcntl.h> +#include <linux/close_range.h> #include <signal.h> #include <stdlib.h> #include <string.h> #include <sys/resource.h> +#include <sys/syscall.h> #include <unistd.h> #include <android/fdsan.h> @@ -49,6 +51,9 @@ static int set_cloexec(int i) { // mark all open fds except stdin/out/err as close-on-exec static int cloexec_except_stdioe() { + // requires 5.11+ or ACK 5.10-T kernel, otherwise returns ENOSYS or EINVAL + if (!syscall(SYS_close_range, 3, ~0U, CLOSE_RANGE_CLOEXEC)) return 0; + // unfortunately getrlimit can lie: // - both soft and hard limits can be lowered to 0, with fds still open, so it can underestimate // - in practice it usually is some really large value (like 32K or more) |