aboutsummaryrefslogtreecommitdiffstats
path: root/lib/runtime_tools/c_src
diff options
context:
space:
mode:
authorZandra Hird <[email protected]>2015-07-07 15:17:10 +0200
committerZandra Hird <[email protected]>2015-07-07 15:17:10 +0200
commit832aa9e06aced4975c9cb02257f74827602217aa (patch)
tree4f5e5263bd6e578fe6fa2a619bfd3bec9a0c512b /lib/runtime_tools/c_src
parentddc7ce9124a8fb03bb95b5d550812c34f4177946 (diff)
parent12002949e5435d19c750fe2cd8e897b4059f875a (diff)
downloadotp-832aa9e06aced4975c9cb02257f74827602217aa.tar.gz
otp-832aa9e06aced4975c9cb02257f74827602217aa.tar.bz2
otp-832aa9e06aced4975c9cb02257f74827602217aa.zip
Merge branch 'maint-17' into maint
Conflicts: OTP_VERSION erts/doc/src/notes.xml erts/vsn.mk lib/runtime_tools/doc/src/notes.xml lib/runtime_tools/vsn.mk otp_versions.table
Diffstat (limited to 'lib/runtime_tools/c_src')
-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;
}