-O pid: show/log process id of running tfcrypt.
[tfcrypt.git] / tfc_error.c
index 3d95eba0cae6387a14800c4dfa7705ee52c1e447..9bface14b50b5b13535f703ce82c188df21ecf1f 100644 (file)
@@ -39,7 +39,7 @@ void xerror(tfc_yesno noexit, tfc_yesno noerrno, tfc_yesno nostats, const char *
 
        if (statline_was_shown == YES && do_statline_dynamic == YES) tfc_esay("\n");
 
-       tfc_nfsay(stderr, "%s: ", progname);
+       tfc_nfsay(stderr, "%s: ", tfc_format_pid(progname));
        tfc_vfsay(stderr, NO, fmt, ap);
        if (errno && noerrno == NO) {
                s = strerror(errno);
@@ -62,6 +62,8 @@ _ex:
 
 void xexit(int status)
 {
+       if (status > 1) goto _do_clean_and_exit;
+
        xclose(sfd);
        if (do_ftrunc > TFC_NO_FTRUNC) {
                if (do_ftrunc == TFC_FTRUNC_TAIL) ftrunc_dfd = total_processed_dst;
@@ -70,6 +72,7 @@ void xexit(int status)
        if (do_preserve_time) fcopy_matime(dfd, &s_stat);
        xclose(dfd);
 
+_do_clean_and_exit:
        memset(srcblk, 0, sizeof(srcblk));
        memset(dstblk, 0, sizeof(dstblk));
 
@@ -298,6 +301,7 @@ void usage(void)
        tfc_say("  -E xall: turn on error actions above for all errors, not just EIO errors.");
        tfc_say("  -E xseek: ignore positioning and other seek related errors.");
        tfc_say("    Multiple -E specifiers may be given in separate options.");
+       tfc_say("  -o logfile: redirect all messages to logfile instead of stderr.");
        tfc_say("  -O opts: set options (comma separated list):");
        tfc_say("    sync: request a synchronous I/O for a output,");
        tfc_say("    fsync: on each write() call a corresponding fsync(fd),");
@@ -312,9 +316,12 @@ void usage(void)
        tfc_say("    statless: emit less information in status line (only processed data).");
        tfc_say("    norepeat: do not ask for any possible password confirmations.");
        tfc_say("    showsecrets: show passwords in plaintext instead of masking them.");
+       tfc_say("    finished: add \"finished\" word before status line when work is finished.");
+       tfc_say("    pid: show %s's process id near it's name in error messages, logs etc.", progname);
        tfc_say("    prompt=str: set main password prompts to this string.");
        tfc_say("    macprompt=str: set MAC password prompts to this string.");
        tfc_say("    shorthex: with -H, do not print printable characters, dump only hex string.");
+       tfc_say("    logfile: (same as -o) redirect all messages to logfile instead of stderr.");
        tfc_say("    iobs=val: set IO block size value. Must not exceed %u bytes.", TFC_U(TFC_BLKSIZE));
        tfc_say("    xtsblocks=val: use these nr of TF blocks per XTS block. Default is %u.", TFC_U(TFC_XTSBLOCKS));
        tfc_say("    iseek=val: seek source file/device by these val bytes.");