summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2016-11-13 15:08:33 -0500
committerTavian Barnes <tavianator@tavianator.com>2016-11-13 15:44:48 -0500
commit58b4741d3d8eb50bd265e0aa5603923c1e3c04c4 (patch)
tree8ac8a78995df61d92359e33f5fcbc9a8299e9546 /eval.c
parent1c5168342e5248983d3a7929abaebe16ca3640a3 (diff)
downloadbfs-58b4741d3d8eb50bd265e0aa5603923c1e3c04c4.tar.xz
Redirect stdin from /dev/null for -ok and -okdir.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 54d9a7c..34343d4 100644
--- a/eval.c
+++ b/eval.c
@@ -12,6 +12,7 @@
#include "bfs.h"
#include "bftw.h"
#include "dstring.h"
+#include "util.h"
#include <assert.h>
#include <dirent.h>
#include <errno.h>
@@ -447,8 +448,17 @@ bool eval_exec(const struct expr *expr, struct eval_state *state) {
exec_chdir(ftwbuf);
}
+ if (expr->exec_flags & EXEC_CONFIRM) {
+ if (redirect(STDIN_FILENO, "/dev/null", O_RDONLY) < 0) {
+ perror("redirect()");
+ goto exit;
+ }
+ }
+
execvp(argv[0], argv);
perror("execvp()");
+
+ exit:
_Exit(EXIT_FAILURE);
}