diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2016-11-13 15:08:33 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2016-11-13 15:44:48 -0500 |
commit | 58b4741d3d8eb50bd265e0aa5603923c1e3c04c4 (patch) | |
tree | 8ac8a78995df61d92359e33f5fcbc9a8299e9546 /eval.c | |
parent | 1c5168342e5248983d3a7929abaebe16ca3640a3 (diff) | |
download | bfs-58b4741d3d8eb50bd265e0aa5603923c1e3c04c4.tar.xz |
Redirect stdin from /dev/null for -ok and -okdir.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); } |