+ /*
+ * Error accounting teardown has to be done after the teardown of all
+ * event notifier pipes to ensure that no tracer may try to use the
+ * error accounting facilities.
+ */
+ event_notifier_error_accounting_fini();
+
+ /*
+ * Unloading the kernel modules needs to be done after all kernel
+ * ressources have been released. In our case, this includes the
+ * notification fd, the event notifier group fd, error accounting fd,
+ * all event and event notifier fds, etc.
+ *
+ * In short, at this point, we need to have called close() on all fds
+ * received from the kernel tracer.
+ */
+ if (is_root && !config.no_kernel) {
+ DBG("Unloading kernel modules");
+ modprobe_remove_lttng_all();
+ }
+