diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index 5e6c2b4f0748..76aa5b78243a 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -526,10 +526,13 @@ run(char **argv) case -1: err(1, "vfork"); case 0: + close(0); if (oflag) { - close(0); if (open("/dev/tty", O_RDONLY) == -1) - err(1, "open"); + err(1, "open /dev/tty"); + } else { + if (open("/dev/null", O_RDONLY) == -1) + err(1, "open /dev/null"); } execvp(argv[0], argv); childerr = errno;