File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
#include <assert.h>
2
+ #include <setjmp.h>
2
3
#include <stdio.h>
3
4
#include <stdlib.h>
4
5
#include <sys/uio.h>
@@ -215,6 +216,12 @@ static interface_ref start(VDECONN *vdeconn, struct cli_options *cliopt) {
215
216
return iface ;
216
217
}
217
218
219
+ static sigjmp_buf jmpbuf ;
220
+ static void signalhandler (int signal ) {
221
+ printf ("\nReceived signal %d\n" , signal );
222
+ siglongjmp (jmpbuf , 1 );
223
+ }
224
+
218
225
static void stop (interface_ref iface ) {
219
226
if (iface == NULL ) {
220
227
return ;
@@ -249,6 +256,14 @@ int main(int argc, char *argv[]) {
249
256
fprintf (stderr , "WARNING: Seems running with SETUID. This is insecure and "
250
257
"highly discouraged. See README.md .\n" );
251
258
}
259
+
260
+ if (sigsetjmp (jmpbuf , 1 ) != 0 ) {
261
+ goto done ;
262
+ }
263
+ signal (SIGHUP , signalhandler );
264
+ signal (SIGINT , signalhandler );
265
+ signal (SIGTERM , signalhandler );
266
+
252
267
int pid_fd = -1 ;
253
268
if (cliopt -> pidfile != NULL ) {
254
269
pid_fd = open (cliopt -> pidfile , O_WRONLY | O_CREAT | O_EXLOCK | O_TRUNC | O_NONBLOCK , 0644 );
You can’t perform that action at this time.
0 commit comments