[*San]: handle EINTR.

llvm-svn: 165006
This commit is contained in:
Evgeniy Stepanov 2012-10-02 13:41:40 +00:00
parent 0439f03bcf
commit 49e8576a09
2 changed files with 13 additions and 2 deletions

View File

@ -179,4 +179,10 @@ extern "C" void* _ReturnAddress(void);
# define GET_CURRENT_FRAME() (uptr)0xDEADBEEF
#endif
#define HANDLE_EINTR(res, f) { \
do { \
res = (f); \
} while (res == -1 && errno == EINTR); \
}
#endif // SANITIZER_DEFS_H

View File

@ -29,6 +29,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
namespace __sanitizer {
@ -56,11 +57,15 @@ fd_t internal_open(const char *filename, bool write) {
}
uptr internal_read(fd_t fd, void *buf, uptr count) {
return (uptr)syscall(__NR_read, fd, buf, count);
sptr res;
HANDLE_EINTR(res, (sptr)syscall(__NR_read, fd, buf, count));
return res;
}
uptr internal_write(fd_t fd, const void *buf, uptr count) {
return (uptr)syscall(__NR_write, fd, buf, count);
sptr res;
HANDLE_EINTR(res, (sptr)syscall(__NR_write, fd, buf, count));
return res;
}
uptr internal_filesize(fd_t fd) {