Skip to content
Permalink
Browse files

only set signal handlers for parent process

  • Loading branch information
jacobgorm committed Feb 23, 2020
1 parent d4c9441 commit 83a7215d0fd88df7d6053c3002d07883ec81baed
Showing with 20 additions and 18 deletions.
  1. +20 −18 nbd.c
38 nbd.c
@@ -276,24 +276,6 @@ int main(int argc, char **argv)
}

char *fn = argv[0];
struct sigaction sig;
sig.sa_handler = signal_handler;
sigemptyset(&sig.sa_mask);
sig.sa_flags = 0;
for (int i = 1; i < 31; ++i) {
switch (i) {
case SIGHUP:
case SIGINT:
case SIGCHLD:
sigaction(i, &sig, NULL);
break;
default:
/* some versions of linux will disconnect nbd
* if getting signalled, so ignore as many as we can. */
signal(i, SIG_IGN);
break;
}
}

printf("opening swapimage %s...\n", fn);
aio_global_init();
@@ -405,6 +387,26 @@ int main(int argc, char **argv)
ioh_event_init(&exit_event, close_event_cb, &should_exit);
ioh_event_init(&flushed_event, close_event_cb, &can_exit);

struct sigaction sig;
sig.sa_handler = signal_handler;
sigemptyset(&sig.sa_mask);
sig.sa_flags = 0;
for (int i = 1; i < 31; ++i) {
switch (i) {
case SIGHUP:
case SIGINT:
case SIGCHLD:
sigaction(i, &sig, NULL);
break;
default:
/* some versions of linux will disconnect nbd
* if getting signalled, so ignore as many as we can. */
signal(i, SIG_IGN);
break;
}
}


shell(script, needs_format ? "create" : "open", NULL);

while (!can_exit) {

0 comments on commit 83a7215

Please sign in to comment.
You can’t perform that action at this time.