summaryrefslogtreecommitdiff
path: root/src/daemontools-extras
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-10-14 12:26:49 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-10-14 12:26:49 +0000
commit7530014a3f607db7dbee656b7451d3e0a0ff3f46 (patch)
tree9df35c5ca8b3bd1e28b9b37baa4f39cfee542e36 /src/daemontools-extras
parent1c426e33a39e07f2f06345fdf9f59d993e0ace0a (diff)
downloads6-7530014a3f607db7dbee656b7451d3e0a0ff3f46.tar.xz
s6-log bugfix: only finalize() and exit when all rotations have completed successfully
Diffstat (limited to 'src/daemontools-extras')
-rw-r--r--src/daemontools-extras/s6-log.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index 4c761d0..bbb92b1 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -1216,12 +1216,13 @@ int main (int argc, char const *const *argv)
for (;;)
{
tain_t deadline ;
- int r ;
+ int r = 0 ;
unsigned int xindex0, xindex1 ;
unsigned int i = 0, j = 1 ;
tain_add_g(&deadline, &tain_infinite_relative) ;
if (bufalloc_1->fd == 1 && bufalloc_len(bufalloc_1))
{
+ r = 1 ;
x[j].fd = 1 ;
x[j].events = IOPAUSE_EXCEPT | (bufalloc_len(bufalloc_1) ? IOPAUSE_WRITE : 0) ;
xindex1 = j++ ;
@@ -1233,6 +1234,7 @@ int main (int argc, char const *const *argv)
logdirs[i].xindex = 0 ;
if (bufalloc_len(&logdirs[i].out) || (logdirs[i].rstate != ROTSTATE_WRITABLE))
{
+ r = 1 ;
if (!tain_future(&logdirs[i].deadline))
{
x[j].fd = logdirs[i].fd ;
@@ -1243,7 +1245,7 @@ int main (int argc, char const *const *argv)
deadline = logdirs[i].deadline ;
}
}
- if (!flagexiting && (!flagblock || j == 1))
+ if (!flagexiting && !(flagblock && r))
{
x[j].fd = 0 ;
x[j].events = IOPAUSE_READ ;
@@ -1251,7 +1253,7 @@ int main (int argc, char const *const *argv)
}
else xindex0 = 0 ;
- if (flagexiting && j == 1) break ;
+ if (flagexiting && !r) break ;
r = iopause_g(x, j, &deadline) ;
if (r < 0) strerr_diefu1sys(111, "iopause") ;