From f63401329d85737bdd0d6d18a629a4036b8ec76f Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 25 Apr 2008 22:12:22 +0200 Subject: [PATCH] New post_crash_dump_hook Run it from crash_dump(). Useful to move core files out of the way, alert deities by e-mail, and so forth. --- include/econfig-spec.h | 2 ++ include/server.h | 1 + src/lib/global/constants.c | 2 ++ src/server/main.c | 1 + src/server/update.c | 3 +-- 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/econfig-spec.h b/include/econfig-spec.h index ee54f8294..bc4ccc6a9 100644 --- a/include/econfig-spec.h +++ b/include/econfig-spec.h @@ -90,6 +90,8 @@ EMPCFBOTH("port", loginport, char *, NSC_STRING, KM_INTERNAL, "TCP port the server will bind") EMPCFBOTH("keep_journal", keep_journal, int, NSC_INT, KM_INTERNAL, "Enable journal log file") +EMPCFBOTH("post_crash_dump_hook", post_crash_dump_hook, char *, NSC_STRING, KM_INTERNAL, + "Shell command run right after a crash dump, in the game's data directory") EMPCFBOTH("privname", privname, char *, NSC_STRING, 0, "Name of the deity") EMPCFBOTH("privlog", privlog, char *, NSC_STRING, 0, diff --git a/include/server.h b/include/server.h index 3bb88196c..bd87510ed 100644 --- a/include/server.h +++ b/include/server.h @@ -49,6 +49,7 @@ void update_main(void); void update_init(void); int update_trigger(void); int update_reschedule(void); +int run_hook(char *, char *); int shutdown_initiate(int); /* thread entry points */ diff --git a/src/lib/global/constants.c b/src/lib/global/constants.c index 97bc28fc3..62ee91caf 100644 --- a/src/lib/global/constants.c +++ b/src/lib/global/constants.c @@ -44,6 +44,8 @@ char *privlog = "careless@invalid"; /* Divine hosts and networks */ char *privip = "127.0.0.1 ::1 ::ffff:127.0.0.1"; +char *post_crash_dump_hook = ""; + char *disabled_commands = ""; int keep_journal = 0; /* journal log file enabled */ diff --git a/src/server/main.c b/src/server/main.c index cc8e66993..03c5b1535 100644 --- a/src/server/main.c +++ b/src/server/main.c @@ -340,6 +340,7 @@ crash_dump(void) return; } } + run_hook(post_crash_dump_hook, "post-crash-dump"); logerror("Crash dump complete"); #endif } diff --git a/src/server/update.c b/src/server/update.c index 06124f43d..5477c0d42 100644 --- a/src/server/update.c +++ b/src/server/update.c @@ -63,7 +63,6 @@ static empth_t *update_thread; static int update_get_schedule(void); static void update_sched(void *); static void update_run(void); -static int run_hook(char *cmd, char *name); void update_init(void) @@ -218,7 +217,7 @@ update_run(void) empth_rwlock_unlock(play_lock); } -static int +int run_hook(char *cmd, char *name) { int status; -- 2.43.0