texpect: Use lib/replace's closefrom()
authorVolker Lendecke <vl@samba.org>
Wed, 15 Jan 2020 11:37:22 +0000 (12:37 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 15 Jan 2020 21:25:34 +0000 (21:25 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/texpect/texpect.c

index 32b2fded41069ac0e57d56714b9cf31441eca94a..797f0a024b4a81fd3a2ba6e78400ac61652ebeab 100644 (file)
@@ -235,23 +235,6 @@ static void parse_configuration(const char *fn)
        fclose(cmd);
 }
 
-/* A wrapper to close als file descriptors above the given fd */
-static int sys_closefrom(int fd)
-{
-       int num = getdtablesize();
-
-       if (num < 0) {
-               num = 1024;
-       }
-
-       for (; fd <= num; fd++) {
-               close(fd);
-       }
-
-       return 0;
-}
-
-
 /*
  *
  */
@@ -463,7 +446,7 @@ int main(int argc, const char **argv)
                        dup2(slave, STDOUT_FILENO);
                        dup2(slave, STDERR_FILENO);
 
-                       sys_closefrom(STDERR_FILENO + 1);
+                       closefrom(STDERR_FILENO + 1);
 
                        /* texpect <expect_instructions> <progname> [<args>] */
                        execvp(program, program_args);