From 2253bb8ec05b4aae013bfae7d0cb42dfcf934143 Mon Sep 17 00:00:00 2001 From: compudj Date: Thu, 15 Sep 2005 05:21:33 +0000 Subject: [PATCH] use daemon() git-svn-id: http://ltt.polymtl.ca/svn@1194 04897980-b3bd-0310-b5e0-8ef037075253 --- ltt/branches/poly/lttd/lttd.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/ltt/branches/poly/lttd/lttd.c b/ltt/branches/poly/lttd/lttd.c index 01f1dd6..3553dfa 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; -- 2.34.1