Skip to content

Stop the framework within signal handler. #488

@PengZheng

Description

@PengZheng

Currently celix_framework_stopBundle is called in signal handler of SIGINT and SIGTERM to stop the framework.
This function calls bunch of unsafe functions, and thus is not async-signal-safe. See man signal-safety for more information.

struct sigaction sigact;
memset(&sigact, 0, sizeof(sigact));
sigact.sa_handler = shutdown_framework;
sigaction(SIGINT, &sigact, NULL);
sigaction(SIGTERM, &sigact, NULL);
memset(&sigact, 0, sizeof(sigact));
sigact.sa_handler = ignore;
sigaction(SIGUSR1, &sigact, NULL);
sigaction(SIGUSR2, &sigact, NULL);
int rc = celixLauncher_launchWithConfigAndProps(config_file, &framework, packedConfig);
if (rc == 0) {
g_fw = framework;
celixLauncher_waitForShutdown(framework);
celixLauncher_destroy(framework);
}
return rc;

We need a reliable mechanism to communicate with the Celix event loop from within a signal handler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions