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 Thursday, at 08:12, David Laight wrote:
| Switching the first two lines:
|                       sv->renamed[fd] = sv_fd;
|                       if (sv_fd == -1) {
|                                  if (errno != EBADF) {
| Will solve that one.
| Which may be why 'EMPTY' is -2, not -1.

Yes, looks fine.

Then, after the "if ((flags & REDIR_PUSH) && sv->renamed[fd] == EMPTY)" block,
you close(fd) on a fd that is potentially closed already. I guess this does not
hurt, though.

FreeBSD do not close(fd) because openredirect() will dup2() into it, so it
will be implicitly closed.


Home | Main Index | Thread Index | Old Index