passt: Also log to stderr, don't fork to background if not interactive

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio 2021-05-21 11:22:04 +02:00
parent 9311ceb8b6
commit 84a62b79a2
2 changed files with 3 additions and 3 deletions

View file

@ -115,4 +115,4 @@ echo
echo "Starting passt..." echo "Starting passt..."
echo echo
ip netns exec "${ns}" ./passt ip netns exec "${ns}" ./passt | cat

View file

@ -797,7 +797,7 @@ int main(int argc, char **argv)
#if DEBUG #if DEBUG
openlog("passt", LOG_PERROR, LOG_DAEMON); openlog("passt", LOG_PERROR, LOG_DAEMON);
#else #else
openlog("passt", 0, LOG_DAEMON); openlog("passt", isatty(fileno(stdout)) ? 0 : LOG_PERROR, LOG_DAEMON);
#endif #endif
get_routes(&c); get_routes(&c);
@ -870,7 +870,7 @@ listen:
" -net nic,model=virtio", sock_index); " -net nic,model=virtio", sock_index);
#ifndef DEBUG #ifndef DEBUG
if (daemon(0, 0)) { if (isatty(fileno(stdout)) && daemon(0, 0)) {
fprintf(stderr, "Failed to fork into background\n"); fprintf(stderr, "Failed to fork into background\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }