Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use g_unix_signal_add instead of sigaction #177

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions app/dockerdwrapperwithcompose.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <arpa/inet.h>
#include <axsdk/axparameter.h>
#include <errno.h>
#include <glib-unix.h>
#include <glib.h>
#include <mntent.h>
#include <netdb.h>
Expand Down Expand Up @@ -176,28 +177,21 @@ static bool prevent_others_from_using_our_ipc_socket(void) {
*
* @param signal_num Signal number.
*/
static void handle_signals(__attribute__((unused)) int signal_num) {
switch (signal_num) {
static gboolean handle_signals(gpointer signal_num) {
switch (GPOINTER_TO_INT(signal_num)) {
case SIGINT:
case SIGTERM:
case SIGQUIT:
quit_program(EX_OK);
}
return G_SOURCE_REMOVE;
}

/**
* @brief Initialize signals
*/
static void init_signals(void) {
struct sigaction sa;

sa.sa_flags = 0;

sigemptyset(&sa.sa_mask);
sa.sa_handler = handle_signals;
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
g_unix_signal_add(SIGINT, handle_signals, GINT_TO_POINTER(SIGINT));
g_unix_signal_add(SIGTERM, handle_signals, GINT_TO_POINTER(SIGTERM));
}

/**
Expand Down