From 0901e361de801b84c0e647d4188d6af7f4082b9c Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Mon, 29 Dec 2025 16:23:14 +0100 Subject: Make sure to clean up temporary directory --- src/main.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 2156e1b..97d57f4 100644 --- a/src/main.c +++ b/src/main.c @@ -308,6 +308,7 @@ static void ftag_export(int argc, char **argv) free(line); /* step 3: invoke tar to build the archive */ + int error = 0; rc = fork(); if (rc == 0) { execlp("tar", @@ -327,16 +328,18 @@ static void ftag_export(int argc, char **argv) wait(&status); if (!(WIFEXITED(status) && WEXITSTATUS(status) == 0)) { fprintf(stderr, "ftag export: child process exited abnormally\n"); - exit(EXIT_FAILURE); + error = 1; } } else { perror("fork"); - exit(EXIT_FAILURE); + error = 1; } /* step 4: clean /tmp */ execlp("rm", "rm", "--recursive", "--force", tmp_dir, NULL); + if (error) + exit(EXIT_FAILURE); } /* Create ftag's database and directories. */ -- cgit v1.2.3