From 22574b3ce2786c44e76fcf3bfb41370d3cf5ce97 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Fri, 23 Dec 2022 20:27:34 -0800 Subject: Fix ^C cannot exit properly --- main.c | 9 +++++++-- sd.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 4652583..a5f091b 100644 --- a/main.c +++ b/main.c @@ -43,11 +43,16 @@ int main(int argc, char **argv) { setbuf(stdout, NULL); a_env.pid = getppid(); signal(SIGHUP, SIG_IGN); - if (sd_setup()) { + int r = sd_setup(); + if (r == -1) { + sd_cleanup(); + return 13; + } + if (r) { sd_cleanup(); return main_consent(0); } else { - int r = main_consent(1); + r = main_consent(1); sd_cleanup(); return r; } diff --git a/sd.c b/sd.c index c987df3..c9e919b 100644 --- a/sd.c +++ b/sd.c @@ -137,7 +137,7 @@ int sd_setup(void) { } case SIGINT: case SIGTERM: { - exit(13); + return -1; } default: { /* Consider insecure. -- cgit v1.2.3