فهرست منبع

* Added -U <binary> which does NOT respawn bots.

svn: 1320
Bryan Drewery 22 سال پیش
والد
کامیت
62f4dc8281
2فایلهای تغییر یافته به همراه16 افزوده شده و 7 حذف شده
  1. 13 7
      src/main.c
  2. 3 0
      src/misc.c

+ 13 - 7
src/main.c

@@ -266,17 +266,19 @@ static void show_help()
   printf(format, STR("-n"), STR("Disables backgrounding first bot in conf"));
   printf(format, STR("-s"), STR("Disables checking for ptrace/strace during startup (no pass needed)"));
   printf(format, STR("-t"), STR("Enables \"Partyline\" emulation (requires -n)"));
+  printf(format, STR("-u <binary>"), STR("Update binary, Automatically kill/respawn bots"));
+  printf(format, STR("-U <binary>"), STR("Update binary"));
   printf(format, "-v", "Displays bot version");
   exit(0);
 }
 
 
 #ifdef LEAF
-# define PARSE_FLAGS "02B:Cd:De:Eg:G:k:L:P:hnstu:v"
+# define PARSE_FLAGS "02B:Cd:De:Eg:G:k:L:P:hnstu:U:v"
 #else /* !LEAF */
-# define PARSE_FLAGS "02Cd:De:Eg:G:hnstu:v"
+# define PARSE_FLAGS "02Cd:De:Eg:G:hnstu:U:v"
 #endif /* HUB */
-#define FLAGS_CHECKPASS "CdDeEgGhkntuv"
+#define FLAGS_CHECKPASS "CdDeEgGhkntuUv"
 static void dtx_arg(int argc, char *argv[])
 {
   int i = 0;
@@ -347,9 +349,10 @@ static void dtx_arg(int argc, char *argv[])
           p = argv[optind];
         got_ed("d", optarg, p);
       case 'u':
+      case 'U':
         if (optarg) {
           update_bin = strdup(optarg);
-          updating++;
+          updating = i == 'u' ? 1 : 2;	/* use 2 if 'U' to not kill/spawn bots. */
           break;
         } else
           exit(0);
@@ -691,10 +694,13 @@ static void startup_checks() {
       exit(0);
     } else {
       if (update_bin)	{			/* invoked with -u bin */
-        kill(conf.bot->pid, SIGKILL);
-        unlink(conf.bot->pid_file);
-        writepid(conf.bot->pid_file, getpid());
+        if (updating != 2) {
+          kill(conf.bot->pid, SIGKILL);
+          unlink(conf.bot->pid_file);
+          writepid(conf.bot->pid_file, getpid());
+        }
         updatebin(DP_STDOUT, update_bin, 1);	/* will call restart all bots */
+        /* never reached */
       }
       spawnbots();
       if (updating)

+ 3 - 0
src/misc.c

@@ -757,6 +757,9 @@ int updatebin(int idx, char *par, int secs)
   }
 
   /* safe to run new binary.. */
+  
+  if (updating == 2) /* dont restart/kill/spawn bots, just die ! */
+    fatal("Binary updated.", 0);
 
 #ifdef LEAF
   if (secs > 0) {