ash: [REDIR] Remove EMFILE special case

Upstream commit:

    Date: Sun, 6 May 2007 12:01:37 +1000
    [REDIR] Remove EMFILE special case

    No caller of copyfd need to ignore EMFILE so we can remove the special
    case and just let it call sh_error on any error.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2016-10-25 19:04:39 +02:00
parent cf98b0c085
commit 20a2cd6291

View File

@ -5190,9 +5190,7 @@ openredirect(union node *redir)
} }
/* /*
* Copy a file descriptor to be >= to. Returns -1 * Copy a file descriptor to be >= to. Throws exception on error.
* if the source file descriptor is closed, EMPTY if there are no unused
* file descriptors left.
*/ */
/* 0x800..00: bit to set in "to" to request dup2 instead of fcntl(F_DUPFD). /* 0x800..00: bit to set in "to" to request dup2 instead of fcntl(F_DUPFD).
* old code was doing close(to) prior to copyfd() to achieve the same */ * old code was doing close(to) prior to copyfd() to achieve the same */
@ -5213,8 +5211,6 @@ copyfd(int from, int to)
newfd = fcntl(from, F_DUPFD, to); newfd = fcntl(from, F_DUPFD, to);
} }
if (newfd < 0) { if (newfd < 0) {
if (errno == EMFILE)
return EMPTY;
/* Happens when source fd is not open: try "echo >&99" */ /* Happens when source fd is not open: try "echo >&99" */
ash_msg_and_raise_error("%d: %m", from); ash_msg_and_raise_error("%d: %m", from);
} }
@ -10243,8 +10239,6 @@ setinputfile(const char *fname, int flags)
if (fd < 10) { if (fd < 10) {
fd2 = copyfd(fd, 10); fd2 = copyfd(fd, 10);
close(fd); close(fd);
if (fd2 < 0)
ash_msg_and_raise_error("out of file descriptors");
fd = fd2; fd = fd2;
} }
setinputfd(fd, flags & INPUT_PUSH_FILE); setinputfd(fd, flags & INPUT_PUSH_FILE);