hush: close-on-exec interactive_fd
authorDenis Vlasenko <vda.linux@googlemail.com>
Mon, 11 Feb 2008 08:39:11 +0000 (08:39 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Mon, 11 Feb 2008 08:39:11 +0000 (08:39 -0000)
shell/hush.c

index 2560d6e97fef9d1da9df370af1bbd2a873939073..29807f88940610fe236371c014e38282facfd778 100644 (file)
@@ -3880,6 +3880,7 @@ int hush_main(int argc, char **argv)
        }
        debug_printf("interactive_fd=%d\n", interactive_fd);
        if (interactive_fd) {
+               fcntl(interactive_fd, F_SETFD, FD_CLOEXEC);
                /* Looks like they want an interactive shell */
                setup_job_control();
                /* -1 is special - makes xfuncs longjmp, not exit
@@ -3907,8 +3908,9 @@ int hush_main(int argc, char **argv)
                                /* give up */
                                interactive_fd = 0;
                }
+               if (interactive_fd)
+                       fcntl(interactive_fd, F_SETFD, FD_CLOEXEC);
        }
-
 #endif
 
        if (argv[optind] == NULL) {