-O finished: prepend "finished: " marker when tfcrypt done (useful for logs).
[tfcrypt.git] / tfcrypt.c
index b6bbe73de3cd3f3d38497fe2c8e11cd2697af735..aa7db33eacba393d5f52be7495bdd184ac2a919b 100644 (file)
--- a/tfcrypt.c
+++ b/tfcrypt.c
@@ -37,7 +37,7 @@ static void open_log(const char *logfile)
        fd = open(logfile, O_WRONLY | O_CREAT | O_LARGEFILE | O_TRUNC, 0666);
        if (fd == -1) xerror(NO, NO, YES, "%s", logfile);
        xclose(2);
-       if (dup2(fd, 2) == -1) xerror(NO, NO, YES, "dup2(%d, 2) for %s", fd, logfile);
+       if (dup2(fd, 2) == -1) xexit(2);
        xclose(fd);
        do_statline_dynamic = NO;
 }
@@ -332,6 +332,8 @@ _baddfname:
                                                do_full_key = YES;
                                        else if (!strcmp(s, "showsecrets"))
                                                show_secrets = YES;
+                                       else if (!strcmp(s, "finished"))
+                                               show_when_done = YES;
                                        else if (!strncmp(s, "logfile", 7) && *(s+7) == '=')
                                                open_log(s+8);
                                        else if (!strncmp(s, "iobs", 4) && *(s+4) == '=') {
@@ -1089,7 +1091,7 @@ _plain:
        sigact.sa_handler = print_crypt_status;
        sigaction(SIGUSR1, &sigact, NULL);
        sigaction(SIGALRM, &sigact, NULL);
-       if (status_timer) setup_next_alarm(status_timer);
+       if (status_timer) setup_next_alarm(status_timer > 1000000 ? 1000000 : status_timer);
        sigact.sa_handler = change_status_width;
        sigaction(SIGQUIT, &sigact, NULL);
        sigact.sa_handler = change_status_timer;