diff options
| author | Junio C Hamano <gitster@pobox.com> | 2021-03-04 15:34:45 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2021-03-04 15:34:45 -0800 |
| commit | 921846fa22adb0abc3fb35e18c6be5feb5091cdd (patch) | |
| tree | 4b53b3b120ff88bf1e1e93d7e36902d1aa5d8a8f /compat/open.c | |
| parent | Merge https://github.com/prati0100/git-gui (diff) | |
| parent | config.mak.uname: enable OPEN_RETURNS_EINTR for macOS Big Sur (diff) | |
| download | git-921846fa22adb0abc3fb35e18c6be5feb5091cdd.tar.gz git-921846fa22adb0abc3fb35e18c6be5feb5091cdd.zip | |
Merge branch 'jk/open-returns-eintr'
Work around platforms whose open() is reported to return EINTR (it
shouldn't, as we do our signals with SA_RESTART).
* jk/open-returns-eintr:
config.mak.uname: enable OPEN_RETURNS_EINTR for macOS Big Sur
Makefile: add OPEN_RETURNS_EINTR knob
Diffstat (limited to 'compat/open.c')
| -rw-r--r-- | compat/open.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/compat/open.c b/compat/open.c new file mode 100644 index 0000000000..eb3754a23b --- /dev/null +++ b/compat/open.c @@ -0,0 +1,25 @@ +#include "git-compat-util.h" + +#undef open +int git_open_with_retry(const char *path, int flags, ...) +{ + mode_t mode = 0; + int ret; + + /* + * Also O_TMPFILE would take a mode, but it isn't defined everywhere. + * And anyway, we don't use it in our code base. + */ + if (flags & O_CREAT) { + va_list ap; + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + } + + do { + ret = open(path, flags, mode); + } while (ret < 0 && errno == EINTR); + + return ret; +} |
