Browse Source

Re-read config on SIGHUP

Serj Kalichev 6 years ago
parent
commit
1ebf1cde9e
1 changed files with 13 additions and 2 deletions
  1. 13 2
      birq.c

+ 13 - 2
birq.c

@@ -130,14 +130,14 @@ int main(int argc, char **argv)
 		if ((pidfd = open(opts->pidfile,
 			O_WRONLY | O_CREAT | O_EXCL | O_TRUNC,
 			S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)) < 0) {
-			syslog(LOG_WARNING, "Can't open pidfile %s: %s",
+			syslog(LOG_WARNING, "Can't open pidfile %s: %s\n",
 				opts->pidfile, strerror(errno));
 		} else {
 			char str[20];
 			snprintf(str, sizeof(str), "%u\n", getpid());
 			str[sizeof(str) - 1] = '\0';
 			if (write(pidfd, str, strlen(str)) < 0)
-				syslog(LOG_WARNING, "Can't write to %s: %s",
+				syslog(LOG_WARNING, "Can't write to %s: %s\n",
 					opts->pidfile, strerror(errno));
 			close(pidfd);
 		}
@@ -205,6 +205,17 @@ int main(int argc, char **argv)
 			printf("----[ %s ]----------------------------------------------------------------\n", outstr);
 		}
 
+		/* Re-read config file on SIGHUP */
+		if (sighup) {
+			if (!access(opts->cfgfile, R_OK)) {
+				syslog(LOG_ERR, "Re-reading config file\n");
+				if (parse_config(opts->cfgfile, opts))
+					syslog(LOG_ERR, "Error while config file parsing.\n");
+			} else if (opts->cfgfile_userdefined)
+				syslog(LOG_ERR, "Can't find config file.\n");
+			sighup = 0;
+		}
+
 		/* Rescan PCI devices for new IRQs. */
 		scan_irqs(irqs, balance_irqs, pxms);
 		if (opts->verbose)