aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorTristan Riehs <tristan.riehs@inria.fr>2025-12-29 16:23:14 +0100
committerTristan Riehs <tristan.riehs@inria.fr>2025-12-29 16:23:14 +0100
commit0901e361de801b84c0e647d4188d6af7f4082b9c (patch)
tree999375032ab5851e8089213d7f1ad580410fdedd /src/main.c
parentfbb3fb48e43507a6a5d5a4638b7df5661b1804ad (diff)
Make sure to clean up temporary directory
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c7
1 files changed, 5 insertions, 2 deletions
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. */