Ver Fonte

* checkpid() was sending stale pids if no bot struct was sent, I forget the reasoning for this

svn: 1475
Bryan Drewery há 21 anos atrás
pai
commit
aa902b3c23
2 ficheiros alterados com 8 adições e 8 exclusões
  1. 5 5
      src/conf.c
  2. 3 3
      src/main.c

+ 5 - 5
src/conf.c

@@ -292,7 +292,7 @@ init_conf()
  */
 
 pid_t
-checkpid(char *nick, conf_bot * bot)
+checkpid(char *nick, conf_bot *bot)
 {
   FILE *f = NULL;
   char buf[DIRMAX] = "", s[11] = "", *tmpnick = NULL, *tmp_ptr = NULL;
@@ -317,7 +317,7 @@ checkpid(char *nick, conf_bot * bot)
     remove_crlf(s);
     fclose(f);
     xx = atoi(s);
-    if (bot) {
+//    if (bot) {
       int x = 0;
 
       x = kill(xx, SIGCHLD);
@@ -325,9 +325,9 @@ checkpid(char *nick, conf_bot * bot)
         return 0;
       else if (x == 0)
         return xx;
-    } else {
-      return xx ? xx : 0;
-    }
+//    } else {
+//      return xx ? xx : 0;
+//    }
   }
 
   return 0;

+ 3 - 3
src/main.c

@@ -378,8 +378,8 @@ static void dtx_arg(int argc, char *argv[])
         break;
       }
       case 'P':
-        if (atoi(optarg) && (atoi(optarg) != localhub_pid))
-          exit(2);
+        if (atoi(optarg) && localhub_pid && (atoi(optarg) != localhub_pid))
+          exit(3);
         else
           sdprintf("Updating...");
         localhub = 1;
@@ -644,7 +644,7 @@ static void startup_checks(int hack) {
 #endif /* LEAF */
       /* this needs to be both hub/leaf */
       if (update_bin)	{			/* invoked with -u bin */
-        if (updating != 2) {
+        if (updating != 2 && conf.bot->pid) {
           kill(conf.bot->pid, SIGKILL);
           unlink(conf.bot->pid_file);
           writepid(conf.bot->pid_file, getpid());