The fix for >/dev/stdout, including Tor Egge's fix for the bug in the

original attempt of the fix. And yes, this time I've tried to build
world with it and it succeeded.

Submitted by:	Tor Egge
MFC after: 1 week
This commit is contained in:
Sergey Babkin 2002-01-13 14:37:40 +00:00
parent 21f633c5c2
commit 63f901ef53

View File

@ -145,11 +145,8 @@ redirect(redir, flags)
}
if (!try) {
sv->renamed[fd] = i;
close(fd);
}
INTON;
} else {
close(fd);
}
if (fd == 0)
fd0_redirected++;
@ -186,6 +183,7 @@ openredirect(redir, memory)
error("cannot open %s: %s", fname, errmsg(errno, E_OPEN));
movefd:
if (f != fd) {
close(fd);
copyfd(f, fd);
close(f);
}
@ -238,8 +236,10 @@ openredirect(redir, memory)
if (redir->ndup.dupfd >= 0) { /* if not ">&-" */
if (memory[redir->ndup.dupfd])
memory[fd] = 1;
else
else {
close(fd);
copyfd(redir->ndup.dupfd, fd);
}
}
break;
case NHERE: