aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2015-07-08 20:31:16 +0200
committerErlang/OTP <[email protected]>2015-07-08 20:31:16 +0200
commitfc30c4d8342d47bf5d2e0fa680d127e9afce6079 (patch)
tree24b5013f2c57c1b4f9b6036258fd1b97265792b2 /lib
parent0b996eb2bb2ac04a0515d8f113cb6529db5ed272 (diff)
parent9c2d22a6ceff4aa49de6a4e14973ac7b8994261c (diff)
downloadotp-fc30c4d8342d47bf5d2e0fa680d127e9afce6079.tar.gz
otp-fc30c4d8342d47bf5d2e0fa680d127e9afce6079.tar.bz2
otp-fc30c4d8342d47bf5d2e0fa680d127e9afce6079.zip
Merge branch 'rickard/trace-file-eintr-bug/OTP-12890' into maint-18
* rickard/trace-file-eintr-bug/OTP-12890: Handle EINTR in trace_file_drv
Diffstat (limited to 'lib')
-rw-r--r--lib/runtime_tools/c_src/trace_file_drv.c24
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;
}