SIGTSTP: fix quiet mode.
authorAndrey Rys <rys@lynxlynx.ru>
Sun, 28 Nov 2021 00:47:09 +0000 (01:47 +0100)
committerAndrey Rys <rys@lynxlynx.ru>
Sun, 28 Nov 2021 00:47:09 +0000 (01:47 +0100)
VERSION
tfc_random.c
tfc_signal.c
tfc_skein.c
tfcrypt.c
tfcrypt.h

diff --git a/VERSION b/VERSION
index 425151f3a411f5e088d7753e7c8d016303b1b9d1..87523dd7a0632907d61799465827c3f08825fa47 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-40
+41
index b1b64206b9ec01803fdcf6b8e66f32472546cded..2ca459d9e56a3330104b8f82e800d290db52cdc3 100644 (file)
@@ -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));
 
index 09c70476f4367c6eaac5e7bf1fe939efd129420e..b2862eedcdaa53fab7f6c71b13b691dd3ff6563a 100644 (file)
@@ -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);
 }
index 7008e48fb5dd541fc18b5ea0785c60262b692753..3f656696a01a9029bf2f18419feda61b058ab5d6 100644 (file)
@@ -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);
index 15f23e2ea3159a71410c03b43c8abd85ad6cf1fa..3a7d3034bb61e9866521d699f79d1e1cefa4635a 100644 (file)
--- 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));
 
index 90f53700325e89e16a5176be33e9d811129c61b0..e9aedd61ccb3de5e4dc2f2e547d881c35e7f3764 100644 (file)
--- 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);