https://bugs.kde.org/show_bug.cgi?id=439090
--- Comment #6 from Mark Wielaard <m...@klomp.org> --- This is the diff on top of the original: diff --git a/coregrind/m_syswrap/syswrap-linux.c b/coregrind/m_syswrap/syswrap-linux.c index 2840b3af0..63dd1fb66 100644 --- a/coregrind/m_syswrap/syswrap-linux.c +++ b/coregrind/m_syswrap/syswrap-linux.c @@ -13319,7 +13319,7 @@ PRE(sys_close_range) { SysRes res = VG_(mk_SysRes_Success)(0); unsigned int beg, end; - Int last = ARG2; + unsigned int last = ARG2; FUSE_COMPATIBLE_MAY_BLOCK(); PRINT("sys_close_range ( %" FMT_REGWORD "u, %" FMT_REGWORD "u, %" @@ -13343,8 +13343,10 @@ PRE(sys_close_range) beg = end = ARG1; do { - if (end > last || ( end == 2/*stderr*/ && VG_(debugLog_getLevel)() > 0) || - end == VG_(log_output_sink).fd || end == VG_(xml_output_sink).fd) { + if (end > last + || (end == 2/*stderr*/ && VG_(debugLog_getLevel)() > 0) + || end == VG_(log_output_sink).fd + || end == VG_(xml_output_sink).fd) { /* Split the range if it contains a file descriptor we're not * supposed to close. */ if (end - 1 >= beg) @@ -13360,11 +13362,19 @@ PRE(sys_close_range) POST(sys_close_range) { unsigned int fd; + unsigned int last = ARG2; - if (!VG_(clo_track_fds)) + if (!VG_(clo_track_fds) + || (ARG3 & VKI_CLOSE_RANGE_CLOEXEC) != 0) return; - for (fd = ARG1; fd <= ARG2; fd++) + if (last >= VG_(fd_hard_limit)) + last = VG_(fd_hard_limit) - 1; + + for (fd = ARG1; fd <= last; fd++) + if ((fd != 2/*stderr*/ || VG_(debugLog_getLevel)() == 0) + && fd != VG_(log_output_sink).fd + && fd != VG_(xml_output_sink).fd) ML_(record_fd_close)(fd); } diff --git a/include/vki/vki-linux.h b/include/vki/vki-linux.h index 426d9db92..eb4e01b33 100644 --- a/include/vki/vki-linux.h +++ b/include/vki/vki-linux.h @@ -5369,6 +5369,9 @@ struct vki_itimerspec64 { #define VKI_RLIM64_INFINITY (~0ULL) +#define VKI_CLOSE_RANGE_UNSHARE (1U << 1) +#define VKI_CLOSE_RANGE_CLOEXEC (1U << 2) + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ -- You are receiving this mail because: You are watching all bug changes.