From 58b4741d3d8eb50bd265e0aa5603923c1e3c04c4 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 13 Nov 2016 15:08:33 -0500 Subject: Redirect stdin from /dev/null for -ok and -okdir. --- eval.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'eval.c') 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 #include #include @@ -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); } -- cgit v1.2.3