summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetri Latvala <petri.latvala@intel.com>2018-04-30 11:13:47 +0300
committerPetri Latvala <petri.latvala@intel.com>2018-04-30 11:13:47 +0300
commit8dea4c98d3de22f3debe436b8583f2c592190904 (patch)
tree97340bb46064968c780864c002bfd81b68c78256
parent51b127c857941b66a0d39d5e0d123492ebe6fa81 (diff)
Make sure output files end with a newline when resumingigt-runner
-rw-r--r--runner/executor.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/runner/executor.c b/runner/executor.c
index 78a1ba5d..2754f5a2 100644
--- a/runner/executor.c
+++ b/runner/executor.c
@@ -238,8 +238,15 @@ static char *filenames[] = {
static int open_at_end(int dirfd, char *name)
{
- int fd = openat(dirfd, name, O_WRONLY | O_CREAT | O_CLOEXEC, 0666);
+ int fd = openat(dirfd, name, O_RDWR | O_CREAT | O_CLOEXEC, 0666);
+ char last;
+
if (fd >= 0) {
+ if (lseek(fd, -1, SEEK_END) >= 0 &&
+ read(fd, &last, 1) == 1 &&
+ last != '\n') {
+ write(fd, "\n", 1);
+ }
lseek(fd, 0, SEEK_END);
}