[pisa-src] r1510 - trunk/pisacd/cdmain.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Wed, 04 Nov 2009 14:13:46 +0100

Author: tjansen
Date: Wed Nov  4 14:13:45 2009
New Revision: 1510

Log:
pisacd kill flag was broken in multiple ways:

The option is advertised as -k, --kill-running in the usage text, but neither
worked, because -t was added to OPTS rather than -k. --kill-running wasn't
added at all.

Furthermore if the lock file is checked before we get a chance to parse the
command line options we cannot obey a -k.

Modified:
   trunk/pisacd/cdmain.c

Modified: trunk/pisacd/cdmain.c
==============================================================================
--- trunk/pisacd/cdmain.c       Tue Nov  3 18:09:08 2009        (r1509)
+++ trunk/pisacd/cdmain.c       Wed Nov  4 14:13:45 2009        (r1510)
@@ -34,7 +34,7 @@
 
 extern pisa_conf_handle_func_set conf_handle_func_set;
 
-#define OPTS "f:i:p:q:btdvh"
+#define OPTS "f:i:p:q:bkdvh"
 
 /**
  * A set of options, including each long option and single-letter option
@@ -47,6 +47,7 @@
        {"debug",       no_argument,            NULL,   'd'},
        {"version",     no_argument,            NULL,   'v'},
        {"help",        no_argument,            NULL,   'h'},
+       {"kill-running",        no_argument,            NULL,   'k'},
        {NULL,          0,                      NULL,   '\0'}
 };
 
@@ -356,9 +357,6 @@
        /* Set default values in context and config */
        cdctx_init();
 
-       /* Check and create lockfile */
-       pisa_create_lock_file(PISACD_LOCK_FILE, cd_ctx.flag_kill_running);
-
        /* Set default values in config */
        cdconf_init();
 
@@ -367,6 +365,9 @@
         * cdconf_* operations except for cdconf_init. */
        cd_get_cmdargs(argc, argv);
 
+       /* Check and create lockfile */
+       pisa_create_lock_file(PISACD_LOCK_FILE, cd_ctx.flag_kill_running);
+
        /* Check, whether hipd is running. This is a requirement for
         * using pisacd. The output will be written to stderr before
         * pisacd is forking to background */

Other related posts:

  • » [pisa-src] r1510 - trunk/pisacd/cdmain.c - Thomas Jansen