summaryrefslogtreecommitdiffstats
path: root/exec.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-01-18 11:27:54 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-01-18 12:27:29 -0500
commit03563b1407e436b2863509ebf09d412e79cbd1dd (patch)
treed2e5b735c8be3078b7b76c31c9168330a7f2557b /exec.c
parentabbb00766a8d10f63bbafb60bb13eb4672d7f44a (diff)
downloadbfs-03563b1407e436b2863509ebf09d412e79cbd1dd.tar.xz
util: New close() wrappers to check for EBADF and preserve errno
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/exec.c b/exec.c
index 45233e1..310756b 100644
--- a/exec.c
+++ b/exec.c
@@ -1,6 +1,6 @@
/****************************************************************************
* bfs *
- * Copyright (C) 2017-2018 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2017-2022 Tavian Barnes <tavianator@tavianator.com> *
* *
* Permission to use, copy, modify, and/or distribute this software for any *
* purpose with or without fee is hereby granted. *
@@ -308,12 +308,10 @@ static int bfs_exec_openwd(struct bfs_exec *execbuf, const struct BFTW *ftwbuf)
}
/** Close the working directory. */
-static int bfs_exec_closewd(struct bfs_exec *execbuf, const struct BFTW *ftwbuf) {
- int ret = 0;
-
+static void bfs_exec_closewd(struct bfs_exec *execbuf, const struct BFTW *ftwbuf) {
if (execbuf->wd_fd >= 0) {
if (!ftwbuf || execbuf->wd_fd != ftwbuf->at_fd) {
- ret = close(execbuf->wd_fd);
+ xclose(execbuf->wd_fd);
}
execbuf->wd_fd = -1;
}
@@ -323,8 +321,6 @@ static int bfs_exec_closewd(struct bfs_exec *execbuf, const struct BFTW *ftwbuf)
execbuf->wd_path = NULL;
execbuf->wd_len = 0;
}
-
- return ret;
}
/** Actually spawn the process. */