File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change 13
13
#include <stdlib.h>
14
14
#include <unistd.h>
15
15
#include <string.h>
16
+ #include <signal.h>
16
17
#include <errno.h>
17
18
18
19
#include "sockhub.h"
@@ -242,12 +243,23 @@ void ShubInitialize(Shub* shub, ShubParams* params)
242
243
shub -> out_buffer_used = 0 ;
243
244
}
244
245
246
+ static int stop = 0 ;
247
+ static void die (int sig ) {
248
+ stop = 1 ;
249
+ }
245
250
246
251
void ShubLoop (Shub * shub )
247
252
{
248
253
int buffer_size = shub -> params -> buffer_size ;
254
+ signal (SIGINT , die );
255
+ signal (SIGQUIT , die );
256
+ signal (SIGTERM , die );
257
+ signal (SIGHUP , die );
258
+ sigset_t sset ;
259
+ sigfillset (& sset );
260
+ sigprocmask (SIG_UNBLOCK , & sset , NULL );
249
261
250
- while (1 ) {
262
+ while (! stop ) {
251
263
fd_set events ;
252
264
struct timeval tm ;
253
265
int i , rc ;
You can’t perform that action at this time.
0 commit comments