From: compudj Date: Thu, 15 Sep 2005 05:21:33 +0000 (+0000) Subject: use daemon() X-Git-Tag: v0.12.20~2295 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=4d20e4740bdeb063ae9ea0ac32b1988079dfbb83;p=lttv.git use daemon() git-svn-id: http://ltt.polymtl.ca/svn@1194 04897980-b3bd-0310-b5e0-8ef037075253 --- diff --git a/ltt/branches/poly/lttd/lttd.c b/ltt/branches/poly/lttd/lttd.c index 01f1dd6d..3553dfae 100644 --- a/ltt/branches/poly/lttd/lttd.c +++ b/ltt/branches/poly/lttd/lttd.c @@ -513,7 +513,6 @@ void close_channel_trace_pairs(struct channel_trace_fd *fd_pairs) int main(int argc, char ** argv) { int ret; - pid_t pid; struct channel_trace_fd fd_pairs = { NULL, 0 }; struct sigaction act; @@ -526,18 +525,13 @@ int main(int argc, char ** argv) show_info(); if(daemon_mode) { - pid = fork(); - - if(pid > 0) { - /* parent */ - return 0; - } else if(pid < 0) { - /* error */ - printf("An error occured while forking.\n"); - return -1; - } - /* else, we are the child, continue... */ - } + ret = daemon(0, 0); + + if(ret == -1) { + perror("An error occured while daemonizing."); + exit(-1); + } + } /* Connect the signal handlers */ act.sa_handler = handler;