tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: /bin/sh redirection in 'while' loop not closed afterwards?



On Wednesday, at 08:26, David Laight wrote:
|                       if (sv_fd != -1)
|                                 sv->renamed[fd] = sv_fd;
|                       else {
|                                 if (errno != EBADF) {
|                                       INTON;
|                                       error("%d: %s", fd, strerror(errno));
|                                       /* NOTREACHED */
|                               }

--->                            sv->renamed[fd] = CLOSED;
                        }

| makes the logic clearer and probably works.

But you're still missing sv->renamed[fd] = CLOSED, which is used by
popredir() later to restore the initial state.

| Of couse, there should be a check the reason the F_DUPFD failed is a
| problem with the source fd, not something else (eg RLIMIT_NOFILES < 10),

The manual says fnctl() would return EMFILE or ENFILE in this case.
After looking at sys_fcntl(), I really think that it returns EBADF iff source
fd is not open.


Home | Main Index | Thread Index | Old Index