mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Delete broken files if application is interrupted unless the keep-broken option is enabled, and return 1 as exit code on interruption.
This commit is contained in:
parent
dd58a58692
commit
073cdb2175
13
main.c
13
main.c
|
|
@ -145,15 +145,10 @@ static void license(void)
|
|||
|
||||
static void sighandler(int sig __UNUSED__)
|
||||
{
|
||||
struct termios termios_p;
|
||||
|
||||
/* Make sure we haven't died after disabling stdin echo */
|
||||
tcgetattr(fileno(stdin), &termios_p);
|
||||
termios_p.c_lflag |= ECHO;
|
||||
tcsetattr(fileno(stdin), 0, &termios_p);
|
||||
|
||||
unlink_files(control);
|
||||
exit(0);
|
||||
signal(sig, SIG_IGN);
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
print_err("Interrupted\n");
|
||||
fatal_exit(&local_control);
|
||||
}
|
||||
|
||||
static void show_summary(void)
|
||||
|
|
|
|||
7
util.c
7
util.c
|
|
@ -100,6 +100,13 @@ void fatal_exit(rzip_control *control)
|
|||
tcsetattr(fileno(stdin), 0, &termios_p);
|
||||
|
||||
unlink_files(control);
|
||||
if (!STDOUT && !TEST_ONLY && control->outfile) {
|
||||
if (!KEEP_BROKEN) {
|
||||
print_verbose("Deleting broken file %s\n", control->outfile);
|
||||
unlink(control->outfile);
|
||||
} else
|
||||
print_verbose("Keeping broken file %s as requested\n", control->outfile);
|
||||
}
|
||||
fprintf(control->outputfile, "Fatal error - exiting\n");
|
||||
fflush(control->outputfile);
|
||||
exit(1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue