This has been requested a few times.
.\"
.TP
.BI \-\-export " filename"
.\"
.TP
.BI \-\-export " filename"
-On shutdown, and upon receiving SIGUSR1, export the in-memory database
+On shutdown, or upon receiving SIGUSR1 or SIGUSR2,
+export the in-memory database
to the named file, relative to the chroot directory.
If you wish to use \fB\-\-export\fR, you must first specify a
\fB\-\-chroot\fR directory, and it must be writeable by the
to the named file, relative to the chroot directory.
If you wish to use \fB\-\-export\fR, you must first specify a
\fB\-\-chroot\fR directory, and it must be writeable by the
in-memory database.
If an \fB\-\-export\fR file was set, it will first save the database to
file.
in-memory database.
If an \fB\-\-export\fR file was set, it will first save the database to
file.
+Sending SIGUSR2 will save the database without emptying it.
.PP
.\"
.SH FREQUENTLY ASKED QUESTIONS
.PP
.\"
.SH FREQUENTLY ASKED QUESTIONS
static volatile int running = 1;
static void sig_shutdown(int signum _unused_) { running = 0; }
static volatile int running = 1;
static void sig_shutdown(int signum _unused_) { running = 0; }
-static volatile int reset_pending = 0;
-static void sig_reset(int signum _unused_) { reset_pending = 1; }
+static volatile int reset_pending = 0, export_pending = 0;
+static void sig_reset(int signum _unused_)
+{
+ reset_pending = 1;
+ export_pending = 1;
+}
+
+static void sig_export(int signum _unused_) { export_pending = 1; }
/* --- Commandline parsing --- */
static unsigned long
/* --- Commandline parsing --- */
static unsigned long
errx(1, "signal(SIGINT) failed");
if (signal(SIGUSR1, sig_reset) == SIG_ERR)
errx(1, "signal(SIGUSR1) failed");
errx(1, "signal(SIGINT) failed");
if (signal(SIGUSR1, sig_reset) == SIG_ERR)
errx(1, "signal(SIGUSR1) failed");
+ if (signal(SIGUSR2, sig_export) == SIG_ERR)
+ errx(1, "signal(SIGUSR2) failed");
verbosef("entering main loop");
daemonize_finish();
verbosef("entering main loop");
daemonize_finish();
+ if (export_pending) {
+ if (export_fn != NULL)
+ db_export(export_fn);
+ export_pending = 0;
+ }
+
- if (export_fn != NULL) db_export(export_fn); /* FIXME: USR2? */
hosts_db_reset();
graph_reset();
reset_pending = 0;
hosts_db_reset();
graph_reset();
reset_pending = 0;