Only daemonize right before running loop.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Thu, 4 Jun 2009 14:05:03 +0000 (11:05 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Thu, 4 Jun 2009 14:05:03 +0000 (11:05 -0300)
If we daemonize prematurely, the user may not see messages produced by
the options parser, for example. Now, --help works as intended.

improxy.c

index cafc365..b13c49a 100644 (file)
--- a/improxy.c
+++ b/improxy.c
@@ -1,5 +1,6 @@
 /*
 ** Copyright (C) 2006 Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+** Copyright (C) 2009 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
 **  
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU General Public License as published by
@@ -58,8 +59,6 @@ int main (int argc, char** argv)
   gchar* conf_address;
   gint port;
 
-  daemon (0, 0);
-
   gnet_init ();
   im_log_init ();
 
@@ -85,6 +84,8 @@ int main (int argc, char** argv)
   inetaddr = gnet_inetaddr_new_nonblock (conf_address, port);
   gnet_server_new (inetaddr, port, new_client, NULL);
 
+  daemon (0, 0);
+
   g_main_loop_run (g_main_loop_new (g_main_context_default (), TRUE));
 
   return 0;