Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Honor $TEMP and friends when generating anonymous handles #43515

Merged
merged 1 commit into from
Jan 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/cgmemmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ static intptr_t get_anon_hdl(void)
if (check_fd_or_close(fd))
return fd;
# endif
char shm_name[] = "julia-codegen-0123456789-0123456789/tmp///";
char shm_name[PATH_MAX] = "julia-codegen-0123456789-0123456789/tmp///";
pid_t pid = getpid();
// `shm_open` can't be mapped exec on mac
# ifndef _OS_DARWIN_
Expand All @@ -195,8 +195,14 @@ static intptr_t get_anon_hdl(void)
return fd;
}
}
snprintf(shm_name, sizeof(shm_name),
"/tmp/julia-codegen-%d-XXXXXX", (int)pid);
size_t len = sizeof(shm_name);
if (uv_os_tmpdir(shm_name, &len) != 0) {
// Unknown error; default to `/tmp`
snprintf(shm_name, sizeof(shm_name), "/tmp");
len = 4;
}
snprintf(shm_name + len, sizeof(shm_name) - len,
"/julia-codegen-%d-XXXXXX", (int)pid);
fd = mkstemp(shm_name);
if (check_fd_or_close(fd)) {
unlink(shm_name);
Expand Down