Bug fix #263: Always redirect std{out,err} if --logpath is specified

Always redirect std{out,err} if --logpath is specified, instead of only
redirect after fork, to correct the inconsistent behavior of --logpath
when getppid() returns 1. (#263)
This commit is contained in:
Richard Grenville 2015-01-26 21:28:48 +08:00
parent 64b4fe2c72
commit 3b17fe15f0
1 changed files with 4 additions and 1 deletions

View File

@ -4965,7 +4965,6 @@ fork_after(session_t *ps) {
printf_errf("(): freopen() failed.");
return false;
}
success = ostream_reopen(ps, NULL);
return success;
}
@ -7444,6 +7443,10 @@ session_init(session_t *ps_old, int argc, char **argv) {
}
}
// Redirect output stream
if (ps->o.fork_after_register || ps->o.logpath)
ostream_reopen(ps, NULL);
write_pid(ps);
// Free the old session