Avoid lingering stdout fd logit process
Delay duplication of stdout/stderr until after forking a logit
process, otherwise we'd have a ligering reference to stdout/stderr.
@@ -191,9 +191,6 @@ static int lredirect(svc_t *svc)
return -1;
}
- dup2(fd, STDOUT_FILENO);
- dup2(fd, STDERR_FILENO);
-
pid = fork();
if (pid == 0) {
int fds;
@@ -240,6 +237,9 @@ static int lredirect(svc_t *svc)
_exit(0);
}
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+
return close(fd);
}
