lib/util: add pre and post panic action hooks
authorStefan Metzmacher <metze@samba.org>
Tue, 12 Jan 2010 11:17:00 +0000 (12:17 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 20 Jan 2010 08:44:36 +0000 (09:44 +0100)
metze

lib/util/fault.c
lib/util/util.h

index 9262af20b09ab9d7d300f3c450e01a3aaf0412ec..5febf1ae29a99f6c1963ce849d8c9b3cf17afa2b 100644 (file)
@@ -115,6 +115,8 @@ _PUBLIC_ void call_backtrace(void)
 }
 
 _PUBLIC_ const char *panic_action = NULL;
+_PUBLIC_ void (*pre_panic_action_hook)(void) = NULL;
+_PUBLIC_ void (*post_panic_action_hook)(void) = NULL;
 
 /**
  Something really nasty happened - panic !
@@ -133,8 +135,17 @@ _PUBLIC_ void smb_panic(const char *why)
                        all_string_sub(cmdstring, "%PROG%", progname, sizeof(cmdstring));
                }
                DEBUG(0, ("smb_panic(): calling panic action [%s]\n", cmdstring));
+
+               if (pre_panic_action_hook) {
+                       pre_panic_action_hook();
+               }
+
                result = system(cmdstring);
 
+               if (post_panic_action_hook) {
+                       post_panic_action_hook();
+               }
+
                if (result == -1)
                        DEBUG(0, ("smb_panic(): fork failed in panic action: %s\n",
                                  strerror(errno)));
index f22c9907d8fe00d32ade8bfa3f8e766a9a6dff12..a67321202a20fc36b84da932614d6f526bcec099 100644 (file)
@@ -32,6 +32,8 @@ struct smbsrv_tcon;
 extern const char *logfile;
 #endif
 extern const char *panic_action;
+extern void (*pre_panic_action_hook)(void);
+extern void (*post_panic_action_hook)(void);
 
 /**
  * assert macros