]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/main.c
device_script(): fix our close() action for the case where in or out <= 2;
[ppp.git] / pppd / main.c
index 2c2b8a2fcd853a4267c734f3af24e2c48bfe8596..5f30dd1867cbfd530a5786cfa4970b85e76e7247 100644 (file)
@@ -40,7 +40,7 @@
  * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#define RCSID  "$Id: main.c,v 1.120 2002/12/04 23:03:32 paulus Exp $"
+#define RCSID  "$Id: main.c,v 1.122 2003/02/24 12:46:37 fcusack Exp $"
 
 #include <stdio.h>
 #include <ctype.h>
@@ -1455,12 +1455,19 @@ device_script(program, in, out, dont_wait)
     }
 
     /* dup in and out to fds > 2 */
-    in = dup(in);
-    out = dup(out);
-    if (log_to_fd >= 0) {
-       errfd = dup(log_to_fd);
-    } else {
-       errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600);
+    {
+       int fd1 = in, fd2 = out, fd3 = log_to_fd;
+
+       in = dup(in);
+       out = dup(out);
+       if (log_to_fd >= 0) {
+           errfd = dup(log_to_fd);
+       } else {
+           errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600);
+       }
+       close(fd1);
+       close(fd2);
+       close(fd3);
     }
 
     /* close fds 0 - 2 and any others we can think of */