dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit ccd9cadf4bbc634a0db900e277a1ac2d8e9aa585
parent c9b9858db093523395444ade64769c7a491617b0
Author: Ross Mohn <rpmohn@waxandwane.org>
Date:   Sat, 27 Nov 2010 11:56:42 +0100

madtty: close only valid file descriptors

The for loop wasn't terminated upon the first bad file descriptor.
This resulted in a significant slow down on systems where
sysconf(_SC_OPEN_MAX) reports a huge value (like 2^16 on AIX).

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
madtty.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/madtty.c b/madtty.c @@ -1224,7 +1224,7 @@ pid_t madtty_forkpty(madtty_t *t, const char *p, const char *argv[], const char maxfd = sysconf(_SC_OPEN_MAX); for (fd = 3; fd < maxfd; fd++) - if (close(fd) == EBADF) + if (close(fd) == -1 && errno == EBADF) break; while (envp && envp[0]) {