Skip to content

Add support for signal-related types/functions in wrapped_facade_headers #58

@coderabbitai

Description

@coderabbitai

Request

Add support in wrapped_facade_headers for signal-related types and functions (e.g., kill, sigaction, sigemptyset, std::sig_atomic_t, pid_t).

Background

In the Spider project, we're using signal handling functions and types for graceful termination when receiving signals like SIGTERM. Currently, we have to add linter suppressions (NOLINTNEXTLINE(misc-include-cleaner)) when using these functions:

// Send SIGTERM to task executor
pid_t const pid = spider::core::ChildPid::get_pid();
if (pid > 0) {
    // NOLINTNEXTLINE(misc-include-cleaner)
    kill(pid, SIGTERM);
}

Similarly for using sigaction, sigemptyset and other signal-related functions:

// NOLINTBEGIN(misc-include-cleaner)
struct sigaction sig_action{};
sig_action.sa_handler = stop_task_handler;
sigemptyset(&sig_action.sa_mask);
sig_action.sa_flags |= SA_RESTART;
if (0 != sigaction(SIGTERM, &sig_action, nullptr)) {
    spdlog::error("Fail to install signal handler for SIGTERM: errno {}", errno);
    return cSignalHandleErr;
}
// NOLINTEND(misc-include-cleaner)

Implementation suggestion

Add appropriate wrappers in wrapped_facade_headers for:

  • kill function from <signal.h>/<csignal>
  • sigaction, sigemptyset and other signal handling functions
  • Signal-related types like pid_t and std::sig_atomic_t

References

This issue was identified during review of y-scope/spider#104, which implements graceful exit when receiving SIGTERM.

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