mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-04 12:52:15 +00:00
- Use _PATH_TTY and _PATH_DEVNULL macros.
- Don't fail if we can't open /dev/null since this can happen if xargs is jail'ed or chroot'ed. These fixes were submitted by Todd Miller from the OpenBSD project. There was one problem in those fixes that broke -o, which is corrected here and should be committed to the OpenBSD repo by Todd soon. MFC in: 3 days
This commit is contained in:
parent
0d3b8ac42c
commit
0792992c73
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116302
@ -483,6 +483,7 @@ static void
|
||||
run(char **argv)
|
||||
{
|
||||
pid_t pid;
|
||||
int fd;
|
||||
char **avec;
|
||||
|
||||
/*
|
||||
@ -521,13 +522,16 @@ run(char **argv)
|
||||
case -1:
|
||||
err(1, "vfork");
|
||||
case 0:
|
||||
close(0);
|
||||
if (oflag) {
|
||||
if (open("/dev/tty", O_RDONLY) == -1)
|
||||
err(1, "open /dev/tty");
|
||||
if ((fd = open(_PATH_TTY, O_RDONLY)) == -1)
|
||||
err(1, "can't open /dev/tty");
|
||||
} else {
|
||||
if (open("/dev/null", O_RDONLY) == -1)
|
||||
err(1, "open /dev/null");
|
||||
fd = open(_PATH_DEVNULL, O_RDONLY);
|
||||
}
|
||||
if (fd > STDIN_FILENO) {
|
||||
if (dup2(fd, STDIN_FILENO) != 0)
|
||||
err(1, "can't dup2 to stdin");
|
||||
close(fd);
|
||||
}
|
||||
execvp(argv[0], argv);
|
||||
childerr = errno;
|
||||
|
Loading…
Reference in New Issue
Block a user