mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 04:03:11 +00:00
Use O_CLOEXEC when opening THP sysfs file in init_thp_state.
This commit is contained in:
committed by
Slobodan Predolac
parent
c597d73778
commit
d0705543e0
@@ -826,8 +826,16 @@ init_thp_state(void) {
|
|||||||
static const char sys_state_never[] = "always madvise [never]\n";
|
static const char sys_state_never[] = "always madvise [never]\n";
|
||||||
char buf[sizeof(sys_state_madvise)];
|
char buf[sizeof(sys_state_madvise)];
|
||||||
|
|
||||||
|
# if defined(O_CLOEXEC)
|
||||||
|
int fd = malloc_open(
|
||||||
|
"/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY | O_CLOEXEC);
|
||||||
|
# else
|
||||||
int fd = malloc_open(
|
int fd = malloc_open(
|
||||||
"/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY);
|
"/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY);
|
||||||
|
if (fd != -1) {
|
||||||
|
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC);
|
||||||
|
}
|
||||||
|
# endif
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
goto label_error;
|
goto label_error;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user