bt_common_abort(): optionally execute a custom command before aborting
[babeltrace.git] / src / common / common.c
index 641f16fddf4f76338757ca307e9eef41b079b947..3acad47cfd88a2671293442f0f3f89894be5a967 100644 (file)
@@ -1905,5 +1905,20 @@ end:
 BT_HIDDEN
 void bt_common_abort(void)
 {
+       static const char * const exec_on_abort_env_name =
+               "BABELTRACE_EXEC_ON_ABORT";
+       const char *env_exec_on_abort;
+
+       env_exec_on_abort = getenv(exec_on_abort_env_name);
+       if (env_exec_on_abort) {
+               if (bt_common_is_setuid_setgid()) {
+                       goto do_abort;
+               }
+
+               (void) g_spawn_command_line_sync(env_exec_on_abort,
+                           NULL, NULL, NULL, NULL);
+       }
+
+do_abort:
        abort();
 }
This page took 0.023218 seconds and 4 git commands to generate.