X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tfc_signal.c;h=659e9381ec181514d8cddacf785ad79ef898f03c;hb=a874fa08a172c1d5006d15d05e494e1b9fbda211;hp=550b6c4d0ae1f5c74213495cb7030f593907cb88;hpb=f761a53231d1a023e2d3e5efcc5591b04a34f98a;p=tfcrypt.git diff --git a/tfc_signal.c b/tfc_signal.c index 550b6c4..659e938 100644 --- a/tfc_signal.c +++ b/tfc_signal.c @@ -39,10 +39,10 @@ void print_crypt_status(int signal) double seconds, human_totalproc_src, human_totalproc_dst, human_wr_speed; int src_scale_idx, dst_scale_idx, wr_speed_scale; const char *oper_mode, *inplace; - static tfc_yesno last, was_sigint; + static tfc_yesno last; if (last == YES) return; - if (signal == 0) last = YES; + if (signal == 0 || signal == -1) last = YES; switch (do_edcrypt) { case TFC_DO_ENCRYPT: oper_mode = "encrypted"; break; @@ -55,16 +55,11 @@ void print_crypt_status(int signal) } if (signal == SIGINT || signal == SIGTERM) { - if (signal == SIGINT) was_sigint = YES; - if (do_stop == TFC_STOP_FULL) xexit(0); - do_stop = TFC_STOP_FULL; - status_timer = 0; - verbose = NO; - if (bench_timer) goto _out; - return; + do_stop = YES; } -_out: tfc_getcurtime(¤t_time); + tfc_getcurtime(¤t_time); + total_time += (current_time - delta_time); seconds = TFC_UTODSECS(current_time - delta_time); wr_speed = delta_processed / seconds; tfc_describescale(total_processed_src, &human_totalproc_src, &src_scale_idx); @@ -80,7 +75,7 @@ _out: tfc_getcurtime(¤t_time); 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)); - if (was_sigint == NO) tfc_esay("\n"); + tfc_esay("\n"); xexit(0); } @@ -90,41 +85,44 @@ _out: tfc_getcurtime(¤t_time); if (do_less_stats == YES) { tfc_nfsay(stderr, "%s%s:" " %s %.2f%s," - " %.2f%s B/s", + " %.2f%s B/s @%s", inplace, progname, oper_mode, human_totalproc_dst, tfc_getscale(dst_scale_idx), - human_wr_speed, tfc_getscale(wr_speed_scale)); + human_wr_speed, tfc_getscale(wr_speed_scale), tfc_format_time(total_time)); } else { if (ctr_mode <= TFC_MODE_PLAIN) tfc_nfsay(stderr, "%s%s: read: %llu (%.2f%s)," " %s %llu (%.2f%s) bytes," - " (%llu (%.2f%s) B/s)", + " (%llu (%.2f%s) B/s), time %s", inplace, progname, total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx), oper_mode, total_processed_dst, human_totalproc_dst, tfc_getscale(dst_scale_idx), - wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale)); + wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale), tfc_format_time(total_time)); else tfc_nfsay(stderr, "%s%s: read: %llu (%.2f%s)," " %s %s %llu (%.2f%s) bytes," - " (%llu (%.2f%s) B/s)", + " (%llu (%.2f%s) B/s), time %s", inplace, progname, total_processed_src, human_totalproc_src, tfc_getscale(src_scale_idx), tfc_modename(ctr_mode), oper_mode, total_processed_dst, human_totalproc_dst, tfc_getscale(dst_scale_idx), - wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale)); + wr_speed, human_wr_speed, tfc_getscale(wr_speed_scale), tfc_format_time(total_time)); } - if ((do_statline_dynamic == NO || last == YES || signal == -1) && was_sigint == NO) tfc_esay("\n"); + if (do_stop == NO && do_statline_dynamic == NO) tfc_esay("\n"); + if (last) tfc_esay("\n"); statline_was_shown = YES; + if ((signal == SIGINT || signal == SIGTERM) && do_stop == YES) { + tfc_esay("\n"); + exit_sigterm(signal); + } + delta_processed = 0; tfc_getcurtime(&delta_time); - if (signal == SIGTSTP) { - tfc_esay("stopping."); - kill(getpid(), SIGSTOP); - } + if (signal == SIGTSTP) kill(getpid(), SIGSTOP); if (status_timer) setup_next_alarm(status_timer); }