[PATCH v1 4/5] pb-discover: Fix signal handler
Geoff Levand
geoff at infradead.org
Mon Apr 27 13:38:31 AEST 2020
Variables shared between signal handlers and the main program
need to be of type 'volatile sig_atomic_t'. Also, after a
signal is serviced it should be re-enabled, so add a call to
signal() in the handler.
Signed-off-by: Geoff Levand <geoff at infradead.org>
---
discover/pb-discover.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/discover/pb-discover.c b/discover/pb-discover.c
index e2b36dd..f67eea5 100644
--- a/discover/pb-discover.c
+++ b/discover/pb-discover.c
@@ -113,11 +113,12 @@ static int opts_parse(struct opts *opts, int argc, char *argv[])
return optind != argc;
}
-static int running;
+static volatile sig_atomic_t running;
-static void sigint_handler(int __attribute__((unused)) signum)
+static void sigint_handler(int signum)
{
running = 0;
+ signal(signum, sigint_handler);
}
int main(int argc, char *argv[])
--
2.20.1
More information about the Petitboot
mailing list