aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-08-26 12:59:17 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-08-26 12:59:17 +0000
commitf7d7aa27e1c4864eb85b6812980df0498fc4c992 (patch)
treefaa6f7d08d3b3312b736793046b8375177957482 /mandocdb.c
parentcc41b18e34d71f6b71a09e42ef7317cbc7dedc57 (diff)
downloadmandoc-f7d7aa27e1c4864eb85b6812980df0498fc4c992.tar.gz
mandoc-f7d7aa27e1c4864eb85b6812980df0498fc4c992.tar.zst
mandoc-f7d7aa27e1c4864eb85b6812980df0498fc4c992.zip
No need to fork and exec rm(1) -rf, we know that we have exactly
one file and exactly one directory to remove. While here, increase the size of the buffer such that the file name actually fits. Minus 17 lines of code, no functional change. Opportunity for simplification reported by George Brown <321 dot george at gmail dot com> on misc@.
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 26117cf8..2f34f487 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.253 2017/07/28 14:48:25 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.254 2017/08/26 12:59:17 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -2119,7 +2119,7 @@ dbprune(struct dba *dba)
static void
dbwrite(struct dba *dba)
{
- char tfn[32];
+ char tfn[33];
int status;
pid_t child;
@@ -2193,26 +2193,9 @@ dbwrite(struct dba *dba)
}
out:
+ unlink(tfn);
*strrchr(tfn, '/') = '\0';
- switch (child = fork()) {
- case -1:
- exitcode = (int)MANDOCLEVEL_SYSERR;
- say("", "&fork rm");
- return;
- case 0:
- execlp("rm", "rm", "-rf", tfn, (char *)NULL);
- say("", "&exec rm");
- exit((int)MANDOCLEVEL_SYSERR);
- default:
- break;
- }
- if (waitpid(child, &status, 0) == -1) {
- exitcode = (int)MANDOCLEVEL_SYSERR;
- say("", "&wait rm");
- } else if (WIFSIGNALED(status) || WEXITSTATUS(status)) {
- exitcode = (int)MANDOCLEVEL_SYSERR;
- say("", "%s: Cannot remove temporary directory", tfn);
- }
+ rmdir(tfn);
}
static int