From: Andrey Rys Date: Sun, 28 Nov 2021 00:47:09 +0000 (+0100) Subject: SIGTSTP: fix quiet mode. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=10fd1044fc86d4537fdc6b05320f5a3d3996727d;p=tfcrypt.git SIGTSTP: fix quiet mode. --- diff --git a/VERSION b/VERSION index 425151f..87523dd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -40 +41 diff --git a/tfc_random.c b/tfc_random.c index b1b6420..2ca459d 100644 --- a/tfc_random.c +++ b/tfc_random.c @@ -93,7 +93,6 @@ void gen_write_bytes(const char *foutname, tfc_fsize offset, tfc_fsize nrbytes) sigact.sa_flags = SA_RESTART; sigact.sa_handler = print_crypt_status; sigaction(SIGUSR1, &sigact, NULL); - sigaction(SIGTSTP, &sigact, NULL); sigaction(SIGALRM, &sigact, NULL); if (status_timer) setup_next_alarm(status_timer); sigact.sa_handler = change_status_width; @@ -104,11 +103,14 @@ void gen_write_bytes(const char *foutname, tfc_fsize offset, tfc_fsize nrbytes) sigact.sa_handler = print_crypt_status; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); + sigaction(SIGTSTP, &sigact, NULL); } else { sigact.sa_handler = exit_sigterm; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); + sigact.sa_handler = handle_sigtstp; + sigaction(SIGTSTP, &sigact, NULL); } memset(&sigact, 0, sizeof(struct sigaction)); diff --git a/tfc_signal.c b/tfc_signal.c index 09c7047..b2862ee 100644 --- a/tfc_signal.c +++ b/tfc_signal.c @@ -33,6 +33,11 @@ void exit_sigterm(int signal) xexit(0); } +void handle_sigtstp(int signal) +{ + if (signal == SIGTSTP) kill(getpid(), SIGSTOP); +} + void print_crypt_status(int signal) { tfc_fsize wr_speed; @@ -125,7 +130,7 @@ void print_crypt_status(int signal) delta_processed = 0; tfc_getcurtime(&delta_time); - if (signal == SIGTSTP) kill(getpid(), SIGSTOP); + handle_sigtstp(signal); if (status_timer) setup_next_alarm(status_timer); } diff --git a/tfc_skein.c b/tfc_skein.c index 7008e48..3f65669 100644 --- a/tfc_skein.c +++ b/tfc_skein.c @@ -170,7 +170,6 @@ _dothat: sigact.sa_flags = SA_RESTART; sigact.sa_handler = print_crypt_status; sigaction(SIGUSR1, &sigact, NULL); - sigaction(SIGTSTP, &sigact, NULL); sigaction(SIGALRM, &sigact, NULL); sigact.sa_handler = change_status_width; sigaction(SIGQUIT, &sigact, NULL); @@ -179,6 +178,8 @@ _dothat: sigact.sa_handler = exit_sigterm; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); + sigact.sa_handler = handle_sigtstp; + sigaction(SIGTSTP, &sigact, NULL); memset(&sigact, 0, sizeof(struct sigaction)); tfc_getcurtime(&delta_time); diff --git a/tfcrypt.c b/tfcrypt.c index 15f23e2..3a7d303 100644 --- a/tfcrypt.c +++ b/tfcrypt.c @@ -1071,7 +1071,6 @@ _plain: sigact.sa_flags = SA_RESTART; sigact.sa_handler = print_crypt_status; sigaction(SIGUSR1, &sigact, NULL); - sigaction(SIGTSTP, &sigact, NULL); sigaction(SIGALRM, &sigact, NULL); if (status_timer) setup_next_alarm(status_timer); sigact.sa_handler = change_status_width; @@ -1082,11 +1081,14 @@ _plain: sigact.sa_handler = print_crypt_status; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); + sigaction(SIGTSTP, &sigact, NULL); } else { sigact.sa_handler = exit_sigterm; sigaction(SIGINT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); + sigact.sa_handler = handle_sigtstp; + sigaction(SIGTSTP, &sigact, NULL); } memset(&sigact, 0, sizeof(struct sigaction)); diff --git a/tfcrypt.h b/tfcrypt.h index 90f5370..e9aedd6 100644 --- a/tfcrypt.h +++ b/tfcrypt.h @@ -200,6 +200,7 @@ void hex2bin(void *d, const char *s); void tfc_finirandom(void); void tfc_getrandom(void *buf, size_t sz); void exit_sigterm(int signal); +void handle_sigtstp(int signal); void print_crypt_status(int signal); void change_status_width(int signal); void change_status_timer(int signal);