mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-26 10:37:19 +03:00
Use O_CLOEXEC when opening THP sysfs file in init_thp_state.
This commit is contained in:
parent
c597d73778
commit
d0705543e0
1 changed files with 8 additions and 0 deletions
|
|
@ -826,8 +826,16 @@ init_thp_state(void) {
|
|||
static const char sys_state_never[] = "always madvise [never]\n";
|
||||
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(
|
||||
"/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) {
|
||||
goto label_error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue