In preparation for adding support for subprocesses: store the pid of
the main process and use it such that we don't try to unload the
mockup module twice leading to a splat from libkmod.
Signed-off-by: Bartosz Golaszewski <bartekgola@gmail.com>
struct kmod_ctx *module_ctx;
struct kmod_module *module;
struct test_context test_ctx;
+ pid_t main_pid;
} globals;
enum {
static void module_cleanup(void)
{
+ /* Don't cleanup from child processes. */
+ if (globals.main_pid != getpid())
+ return;
+
msg("cleaning up");
if (mockup_loaded())
{
struct _test_case *test;
+ globals.main_pid = getpid();
atexit(module_cleanup);
msg("libgpiod test suite");