use daemon()
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Sep 2005 05:21:33 +0000 (05:21 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 15 Sep 2005 05:21:33 +0000 (05:21 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1194 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/lttd/lttd.c

index 01f1dd6dc262a7f5e9bdb6a6200ffefa0699a846..3553dfaeda2191c8a84cce896c65b8fe69b2b359 100644 (file)
@@ -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;
This page took 0.023723 seconds and 4 git commands to generate.