Sure.

But always be careful that the fd loop isn't bounded for a reason,
for instance some fd at > 20 that it wanted left open.

> This variable reuse has a funny smell.
> 
> Index: usr.bin/ftp/cmds.c
> ===================================================================
> RCS file: /var/cvs/src/usr.bin/ftp/cmds.c,v
> retrieving revision 1.79
> diff -u -p -r1.79 cmds.c
> --- usr.bin/ftp/cmds.c        21 Jan 2017 08:33:07 -0000      1.79
> +++ usr.bin/ftp/cmds.c        23 Jan 2018 08:40:32 -0000
> @@ -987,8 +987,7 @@ shell(int argc, char *argv[])
>       old1 = signal (SIGINT, SIG_IGN);
>       old2 = signal (SIGQUIT, SIG_IGN);
>       if ((pid = fork()) == 0) {
> -             for (pid = 3; pid < 20; pid++)
> -                     (void)close(pid);
> +             (void)closefrom(3);
>               (void)signal(SIGINT, SIG_DFL);
>               (void)signal(SIGQUIT, SIG_DFL);
>               shellp = getenv("SHELL");
> 

Reply via email to