File tree 1 file changed +6
-12
lines changed
1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 24
24
#include <arpa/inet.h>
25
25
#include <axsdk/axparameter.h>
26
26
#include <errno.h>
27
+ #include <glib-unix.h>
27
28
#include <glib.h>
28
29
#include <mntent.h>
29
30
#include <netdb.h>
@@ -176,28 +177,21 @@ static bool prevent_others_from_using_our_ipc_socket(void) {
176
177
*
177
178
* @param signal_num Signal number.
178
179
*/
179
- static void handle_signals (__attribute__(( unused )) int signal_num ) {
180
- switch (signal_num ) {
180
+ static gboolean handle_signals (gpointer signal_num ) {
181
+ switch (GPOINTER_TO_INT ( signal_num ) ) {
181
182
case SIGINT :
182
183
case SIGTERM :
183
- case SIGQUIT :
184
184
quit_program (EX_OK );
185
185
}
186
+ return G_SOURCE_REMOVE ;
186
187
}
187
188
188
189
/**
189
190
* @brief Initialize signals
190
191
*/
191
192
static void init_signals (void ) {
192
- struct sigaction sa ;
193
-
194
- sa .sa_flags = 0 ;
195
-
196
- sigemptyset (& sa .sa_mask );
197
- sa .sa_handler = handle_signals ;
198
- sigaction (SIGINT , & sa , NULL );
199
- sigaction (SIGTERM , & sa , NULL );
200
- sigaction (SIGQUIT , & sa , NULL );
193
+ g_unix_signal_add (SIGINT , handle_signals , GINT_TO_POINTER (SIGINT ));
194
+ g_unix_signal_add (SIGTERM , handle_signals , GINT_TO_POINTER (SIGTERM ));
201
195
}
202
196
203
197
/**
You can’t perform that action at this time.
0 commit comments