xexit: do post-crypt work only if exiting by system error or normally.
[tfcrypt.git] / tfc_signal.c
index 09c70476f4367c6eaac5e7bf1fe939efd129420e..4c918193f9f44ebfc1493e80a6a3e7ee7d31292e 100644 (file)
@@ -33,6 +33,18 @@ void exit_sigterm(int signal)
        xexit(0);
 }
 
+void handle_sigtstp(int signal)
+{
+       if (signal == SIGTSTP) {
+               tfc_useconds freeze_start, freeze_end;
+
+               tfc_getcurtime(&freeze_start);
+               kill(getpid(), SIGSTOP);
+               tfc_getcurtime(&freeze_end);
+               total_time -= (freeze_end - freeze_start);
+       }
+}
+
 void print_crypt_status(int signal)
 {
        tfc_fsize wr_speed;
@@ -74,8 +86,7 @@ void print_crypt_status(int signal)
                        "avg. speed %llu (%.2f%s) B/s, time %.4fs.",
                        oper_mode,
                        total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx),
-                       wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale),
-                       TFC_UTODSECS(current_time - delta_time));
+                       wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale), seconds);
                tfc_esay("\n");
                xexit(0);
        }
@@ -125,7 +136,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);
 }