diff options
author | Zandra Hird <[email protected]> | 2015-07-07 15:20:40 +0200 |
---|---|---|
committer | Zandra Hird <[email protected]> | 2015-07-07 15:20:40 +0200 |
commit | 9ebb4472d9cbe0dc907c894231ce1f61a04fa0b6 (patch) | |
tree | 21b4f9898de2e67f515c6cf16a207f7b592dbe05 /lib | |
parent | 5b9d3387bac102ee3a8114e2b3316abd86d2e1fb (diff) | |
parent | 832aa9e06aced4975c9cb02257f74827602217aa (diff) | |
download | otp-9ebb4472d9cbe0dc907c894231ce1f61a04fa0b6.tar.gz otp-9ebb4472d9cbe0dc907c894231ce1f61a04fa0b6.tar.bz2 otp-9ebb4472d9cbe0dc907c894231ce1f61a04fa0b6.zip |
Merge branch 'maint'
Diffstat (limited to 'lib')
-rw-r--r-- | lib/runtime_tools/c_src/trace_file_drv.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/runtime_tools/c_src/trace_file_drv.c b/lib/runtime_tools/c_src/trace_file_drv.c index 7549161e05..a63a7d3ad9 100644 --- a/lib/runtime_tools/c_src/trace_file_drv.c +++ b/lib/runtime_tools/c_src/trace_file_drv.c @@ -327,9 +327,11 @@ static ErlDrvData trace_file_start(ErlDrvPort port, char *buff) | O_BINARY #endif , 0777)) < 0) { + int saved_errno = errno; if (wrap) driver_free(wrap); driver_free(data); + errno = saved_errno; return ERL_DRV_ERROR_ERRNO; } @@ -525,14 +527,19 @@ static void *my_alloc(size_t size) ** A write wrapper that regards it as an error if not all data was written. */ static int do_write(FILETYPE fd, unsigned char *buff, int siz) { - int w = write(fd, buff, siz); - if (w != siz) { - if (w >= 0) { - errno = ENOSPC; + int w; + while (1) { + w = write(fd, buff, siz); + if (w < 0 && errno == EINTR) + continue; + else if (w != siz) { + if (w >= 0) { + errno = ENOSPC; + } + return -1; } - return -1; + return siz; } - return siz; } /* @@ -627,8 +634,10 @@ static void close_unlink_port(TraceFileData *data) */ static int wrap_file(TraceFileData *data) { if (my_flush(data) < 0) { + int saved_errno = errno; close(data->fd); data->fd = -1; + errno = saved_errno; return -1; } close(data->fd); @@ -644,12 +653,15 @@ static int wrap_file(TraceFileData *data) { next_name(&data->wrap->del); } next_name(&data->wrap->cur); +try_open: data->fd = open(data->wrap->cur.name, O_WRONLY | O_TRUNC | O_CREAT #ifdef O_BINARY | O_BINARY #endif , 0777); if (data->fd < 0) { + if (errno == EINTR) + goto try_open; data->fd = -1; return -1; } |