use close-on-exec
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Tue, 25 Aug 1992 10:17:45 +0000 (02:17 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Tue, 25 Aug 1992 10:17:45 +0000 (02:17 -0800)
SCCS-vsn: usr.bin/window/compress.c 3.7
SCCS-vsn: usr.bin/window/wwenviron.c 3.28
SCCS-vsn: usr.bin/window/context.c 3.13
SCCS-vsn: usr.bin/window/wwopen.c 3.30
SCCS-vsn: usr.bin/window/wwpty.c 3.20

usr/src/usr.bin/window/compress.c
usr/src/usr.bin/window/context.c
usr/src/usr.bin/window/wwenviron.c
usr/src/usr.bin/window/wwopen.c
usr/src/usr.bin/window/wwpty.c

index 4acefa2..ca2250c 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)compress.c 3.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)compress.c 3.7 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "ww.h"
 #endif /* not lint */
 
 #include "ww.h"
@@ -17,6 +17,7 @@ static char sccsid[] = "@(#)compress.c        3.6 (Berkeley) %G%";
 
        /* special */
 #include <stdio.h>
 
        /* special */
 #include <stdio.h>
+#include <fcntl.h>
 int cc_trace = 0;
 FILE *cc_trace_fp;
 
 int cc_trace = 0;
 FILE *cc_trace_fp;
 
@@ -272,8 +273,10 @@ ccstart()
                p->hback = 0;
        for (p = cc_q1a.qforw; p != &cc_q1a; p = p->qforw)
                p->hback = 0;
                p->hback = 0;
        for (p = cc_q1a.qforw; p != &cc_q1a; p = p->qforw)
                p->hback = 0;
-       if (cc_trace)
+       if (cc_trace) {
                cc_trace_fp = fopen("window-trace", "a");
                cc_trace_fp = fopen("window-trace", "a");
+               (void) fcntl(fileno(cc_trace_fp), F_SETFD, 1);
+       }
 }
 
 ccend()
 }
 
 ccend()
index f05859e..cbfd93a 100644 (file)
@@ -9,12 +9,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)context.c  3.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)context.c  3.13 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "value.h"
 #include "string.h"
 #include "context.h"
 #endif /* not lint */
 
 #include "value.h"
 #include "string.h"
 #include "context.h"
+#include <fcntl.h>
 
 /*
  * Context push/pop for nested command files.
 
 /*
  * Context push/pop for nested command files.
@@ -63,6 +64,7 @@ char *filename;
        cx.x_fp = fopen(filename, "r");
        if (cx.x_fp == 0)
                goto bad;
        cx.x_fp = fopen(filename, "r");
        if (cx.x_fp == 0)
                goto bad;
+       (void) fcntl(fileno(cx.x_fp), F_SETFD, 1);
        cx.x_bol = 1;
        cx.x_lineno = 0;
        cx.x_errwin = 0;
        cx.x_bol = 1;
        cx.x_lineno = 0;
        cx.x_errwin = 0;
index 1aa6636..e58b5e2 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)wwenviron.c        3.27 (Berkeley) %G%";
+static char sccsid[] = "@(#)wwenviron.c        3.28 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "ww.h"
 #endif /* not lint */
 
 #include "ww.h"
@@ -48,8 +48,7 @@ register struct ww *wp;
        (void) dup2(i, 0);
        (void) dup2(i, 1);
        (void) dup2(i, 2);
        (void) dup2(i, 0);
        (void) dup2(i, 1);
        (void) dup2(i, 2);
-       for (i = wwdtablesize - 1; i > 2; i--)
-               (void) close(i);
+       (void) close(i);
 #ifdef TIOCSCTTY
        (void) setsid();
        (void) ioctl(0, TIOCSCTTY, 0);
 #ifdef TIOCSCTTY
        (void) setsid();
        (void) ioctl(0, TIOCSCTTY, 0);
index 8496567..85ce8b6 100644 (file)
@@ -9,12 +9,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)wwopen.c   3.29 (Berkeley) %G%";
+static char sccsid[] = "@(#)wwopen.c   3.30 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "ww.h"
 #include <sys/types.h>
 #include <sys/socket.h>
 #endif /* not lint */
 
 #include "ww.h"
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <fcntl.h>
 
 struct ww *
 wwopen(flags, nrow, ncol, row, col, nline)
 
 struct ww *
 wwopen(flags, nrow, ncol, row, col, nline)
@@ -77,6 +78,8 @@ wwopen(flags, nrow, ncol, row, col, nline)
                        wwerrno = WWE_SYS;
                        goto bad;
                }
                        wwerrno = WWE_SYS;
                        goto bad;
                }
+               (void) fcntl(d[0], F_SETFD, 1);
+               (void) fcntl(d[1], F_SETFD, 1);
                w->ww_pty = d[0];
                w->ww_socket = d[1];
        }
                w->ww_pty = d[0];
                w->ww_socket = d[1];
        }
index ac2ba7a..f747394 100644 (file)
@@ -9,10 +9,11 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)wwpty.c    3.19 (Berkeley) %G%";
+static char sccsid[] = "@(#)wwpty.c    3.20 (Berkeley) %G%";
 #endif /* not lint */
 
 #include "ww.h"
 #endif /* not lint */
 
 #include "ww.h"
+#include <fcntl.h>
 #if !defined(OLD_TTY) && !defined(TIOCPKT)
 #include <sys/ioctl.h>
 #endif
 #if !defined(OLD_TTY) && !defined(TIOCPKT)
 #include <sys/ioctl.h>
 #endif
@@ -50,6 +51,7 @@ register struct ww *w;
                                (void) close(w->ww_pty);
                                continue;
                        }
                                (void) close(w->ww_pty);
                                continue;
                        }
+                       (void) fcntl(w->ww_pty, F_SETFD, 1);
                        return 0;
                }
        }
                        return 0;
                }
        }