mirror of
https://git.proxmox.com/git/libgit2
synced 2025-06-21 10:34:05 +00:00
Merge pull request #1670 from arrbee/open-cloexec
Add O_CLOEXEC to open calls
This commit is contained in:
commit
09ee60c6d4
@ -61,9 +61,11 @@ int git_futils_creat_locked(const char *path, const mode_t mode)
|
|||||||
wchar_t buf[GIT_WIN_PATH];
|
wchar_t buf[GIT_WIN_PATH];
|
||||||
|
|
||||||
git__utf8_to_16(buf, GIT_WIN_PATH, path);
|
git__utf8_to_16(buf, GIT_WIN_PATH, path);
|
||||||
fd = _wopen(buf, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, mode);
|
fd = _wopen(buf, O_WRONLY | O_CREAT | O_TRUNC |
|
||||||
|
O_EXCL | O_BINARY | O_CLOEXEC, mode);
|
||||||
#else
|
#else
|
||||||
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, mode);
|
fd = open(path, O_WRONLY | O_CREAT | O_TRUNC |
|
||||||
|
O_EXCL | O_BINARY | O_CLOEXEC, mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -111,12 +111,12 @@ int p_open(const char *path, int flags, ...)
|
|||||||
va_end(arg_list);
|
va_end(arg_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return open(path, flags | O_BINARY, mode);
|
return open(path, flags | O_BINARY | O_CLOEXEC, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int p_creat(const char *path, mode_t mode)
|
int p_creat(const char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
return open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
|
return open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_CLOEXEC, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
int p_getcwd(char *buffer_out, size_t size)
|
int p_getcwd(char *buffer_out, size_t size)
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
#if !defined(O_BINARY)
|
#if !defined(O_BINARY)
|
||||||
#define O_BINARY 0
|
#define O_BINARY 0
|
||||||
#endif
|
#endif
|
||||||
|
#if !defined(O_CLOEXEC)
|
||||||
|
#define O_CLOEXEC 0
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int git_file;
|
typedef int git_file;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user