Răsfoiți Sursa

* Send SIGUSR1 after exiting from -C

svn: 1881
Bryan Drewery 21 ani în urmă
părinte
comite
a01eeef5e5
4 a modificat fișierele cu 12 adăugiri și 5 ștergeri
  1. 9 2
      src/binary.c
  2. 1 1
      src/binary.h
  3. 1 1
      src/conf.c
  4. 1 1
      src/main.c

+ 9 - 2
src/binary.c

@@ -457,7 +457,7 @@ clear_settings(void)
   memset(&settings.bots, 0, sizeof(settings_t) - 3467);
 }
 
-void conf_to_bin(conf_t *in, bool move, int die)
+void conf_to_bin(conf_t *in, bool move, int die, bool refresh)
 {
   conf_bot *bot = NULL;
   char *newbin = NULL;
@@ -492,7 +492,14 @@ void conf_to_bin(conf_t *in, bool move, int die)
   else
     newbin = binname;
   /* tellconfig(&settings); */
-  write_settings(newbin, die, 1);
+  write_settings(newbin, -1, 1);
+
+  /* alert the localhub of changes */
+  if (refresh && conf.bots && conf.bots->pid)
+    kill(conf.bots->pid, SIGUSR1);
+
+  if (die >= 0)
+    exit(die);
 }
 
 void reload_bin_data() {

+ 1 - 1
src/binary.h

@@ -13,6 +13,6 @@ extern int checked_bin_buf;
 
 void check_sum(const char *, const char *);
 void write_settings(const char *, int, bool);
-void conf_to_bin(conf_t *, bool, int);
+void conf_to_bin(conf_t *, bool, int, bool);
 void reload_bin_data();
 #endif /* !_BINARY_H */

+ 1 - 1
src/conf.c

@@ -257,7 +257,7 @@ confedit()
   readconf((const char *) tmpconf.file, 0);               /* read cleartext conf tmp into &settings */
   fix_tilde(&conf.binpath);
   unlink(tmpconf.file);
-  conf_to_bin(&conf, 0, 1);	/* will exit */
+  conf_to_bin(&conf, 0, 1, 1);	/* will exit */
   exit(0);                      /* never reached */
 
 fatal:

+ 1 - 1
src/main.c

@@ -292,7 +292,7 @@ static void dtx_arg(int argc, char *argv[])
         readconf(optarg, CONF_ENC);
         fix_tilde(&conf.binpath);
         parseconf(0);
-        conf_to_bin(&conf, 0, 6);		/* this will exit() in write_settings() */
+        conf_to_bin(&conf, 0, 6, 0);		/* this will exit() in write_settings() */
       case 'B':
         localhub = 0;
         used_B = 1;