Skip to content

Commit

Permalink
Use g_unix_signal_add instead of sigaction (#177)
Browse files Browse the repository at this point in the history
Co-authored-by: Isak Jakobsson <[email protected]>
  • Loading branch information
github-actions[bot] and isak-jakobsson authored Nov 11, 2024
1 parent dc6cf49 commit 6c00bb6
Showing 1 changed file with 6 additions and 12 deletions.
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

0 comments on commit 6c00bb6

Please sign in to comment.