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
This commit is contained in:
@ -227,6 +227,7 @@ int mingw_rmdir(const char *path);
|
||||
|
||||
int mingw_open (const char *filename, int oflags, ...);
|
||||
#define open mingw_open
|
||||
#undef OPEN_RETURNS_EINTR
|
||||
|
||||
int mingw_fgetc(FILE *stream);
|
||||
#define fgetc mingw_fgetc
|
||||
|
25
compat/open.c
Normal file
25
compat/open.c
Normal file
@ -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;
|
||||
}
|
Reference in New Issue
Block a user