]> diplodocus.org Git - nmh/commitdiff
Garbage collect closefds()
authorKen Hornstein <kenh@pobox.com>
Tue, 23 Apr 2019 00:36:14 +0000 (20:36 -0400)
committerKen Hornstein <kenh@pobox.com>
Tue, 23 Apr 2019 00:36:14 +0000 (20:36 -0400)
Remove the closefds() function; it was used sporadically and was
causing problems on High Sierra.  In the future look at opening
more descriptors with FD_CLOEXEC.

Makefile.am
sbr/closefds.c [deleted file]
sbr/closefds.h [deleted file]
uip/rcvtty.c
uip/replsbr.c
uip/send.c
uip/slocal.c
uip/whatnowsbr.c
uip/whom.c

index 9f6b675c6a8edfcdb55d71ad578d302d57c9adc8..ed7826813f64ff9b5f6695d8ae6e675060d6dfc4 100644 (file)
@@ -361,7 +361,6 @@ noinst_HEADERS = \
     sbr/brkstring.h \
     sbr/check_charset.h \
     sbr/client.h \
     sbr/brkstring.h \
     sbr/check_charset.h \
     sbr/client.h \
-    sbr/closefds.h \
     sbr/concat.h \
     sbr/context_del.h \
     sbr/context_find.h \
     sbr/concat.h \
     sbr/context_del.h \
     sbr/context_find.h \
@@ -1040,7 +1039,6 @@ sbr_libmh_a_SOURCES = \
     sbr/charstring.c \
     sbr/check_charset.c \
     sbr/client.c \
     sbr/charstring.c \
     sbr/check_charset.c \
     sbr/client.c \
-    sbr/closefds.c \
     sbr/concat.c \
     sbr/context_del.c \
     sbr/context_find.c \
     sbr/concat.c \
     sbr/context_del.c \
     sbr/context_find.c \
diff --git a/sbr/closefds.c b/sbr/closefds.c
deleted file mode 100644 (file)
index 4995482..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* closefds.c -- close-up fd's
- *
- * This code is Copyright (c) 2002, by the authors of nmh.  See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information.
- */
-
-#include "h/mh.h"
-#include "closefds.h"
-
-
-void
-closefds(int i)
-{
-    int nbits = OPEN_MAX;
-
-    for (; i < nbits; i++)
-       close (i);
-}
diff --git a/sbr/closefds.h b/sbr/closefds.h
deleted file mode 100644 (file)
index 4bb77cf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/* closefds.h -- close-up fd's
- *
- * This code is Copyright (c) 2017, by the authors of nmh.  See the
- * COPYRIGHT file in the root directory of the nmh distribution for
- * complete copyright information. */
-
-void closefds(int);
index 73440fb0f88401143a492aca37688ce1d2e1db7a..c66f3996b5f8db4a9dd7deadc1a11c5b9afcb263 100644 (file)
@@ -15,7 +15,6 @@
 #include "scansbr.h"
 #include "sbr/getarguments.h"
 #include "sbr/smatch.h"
 #include "scansbr.h"
 #include "sbr/getarguments.h"
 #include "sbr/smatch.h"
-#include "sbr/closefds.h"
 #include "sbr/ambigsw.h"
 #include "sbr/print_version.h"
 #include "sbr/print_help.h"
 #include "sbr/ambigsw.h"
 #include "sbr/print_version.h"
 #include "sbr/print_help.h"
@@ -238,7 +237,6 @@ message_fd (char **vec)
     rewind (stdin);
     if (dup2 (fd, 1) == NOTOK || dup2 (fd, 2) == NOTOK)
        _exit(1);
     rewind (stdin);
     if (dup2 (fd, 1) == NOTOK || dup2 (fd, 2) == NOTOK)
        _exit(1);
-    closefds (3);
     setpgid(0, getpid());      /* put in own process group */
     if (execvp (vec[0], vec) == NOTOK) {
         _exit(1);
     setpgid(0, getpid());      /* put in own process group */
     if (execvp (vec[0], vec) == NOTOK) {
         _exit(1);
index e3c88949111026ad61b09b08ecc70b062075dce9..ed5e94ed9b3cbfa06ea22a2b9f326830897f8c75 100644 (file)
@@ -12,7 +12,6 @@
 #include "sbr/m_getfld.h"
 #include "sbr/read_switch.h"
 #include "sbr/concat.h"
 #include "sbr/m_getfld.h"
 #include "sbr/read_switch.h"
 #include "sbr/concat.h"
-#include "sbr/closefds.h"
 #include "sbr/uprf.h"
 #include "sbr/escape_addresses.h"
 #include "sbr/pidstatus.h"
 #include "sbr/uprf.h"
 #include "sbr/escape_addresses.h"
 #include "sbr/pidstatus.h"
@@ -452,7 +451,6 @@ replfilter (FILE *in, FILE *out, char *filter, int fmtproc)
        case OK:
            dup2 (fileno (in), fileno (stdin));
            dup2 (fileno (out), fileno (stdout));
        case OK:
            dup2 (fileno (in), fileno (stdin));
            dup2 (fileno (out), fileno (stdout));
-           closefds (3);
 
            /*
             * We're not allocating the memory for the extra arguments,
 
            /*
             * We're not allocating the memory for the extra arguments,
index f29bb45fda83a9b963bf8b890eab1c1cf776e959..d3fc4b1cb4b4b9563b24c104c2c2461ee6da3573 100644 (file)
@@ -15,7 +15,6 @@
 #include "sbr/seq_save.h"
 #include "sbr/showfile.h"
 #include "sbr/smatch.h"
 #include "sbr/seq_save.h"
 #include "sbr/showfile.h"
 #include "sbr/smatch.h"
-#include "sbr/closefds.h"
 #include "sbr/cpydata.h"
 #include "sbr/m_draft.h"
 #include "sbr/m_convert.h"
 #include "sbr/cpydata.h"
 #include "sbr/m_draft.h"
 #include "sbr/m_convert.h"
@@ -483,7 +482,6 @@ go_to_it:
        push ();
 
     status = 0;
        push ();
 
     status = 0;
-    closefds (3);
 
     for (msgnum = 0; msgnum < msgp; msgnum++) {
         switch (sendsbr (vec, vecp, program, msgs[msgnum], &st, 1, auth_svc)) {
 
     for (msgnum = 0; msgnum < msgp; msgnum++) {
         switch (sendsbr (vec, vecp, program, msgs[msgnum], &st, 1, auth_svc)) {
index 5eb5243c970c14373885faffd4f02bc45ef2177a..8cca5e355951bbe74a9309af6edd3a61fecd2b57 100644 (file)
@@ -26,7 +26,6 @@
 #include "sbr/getarguments.h"
 #include "sbr/smatch.h"
 #include "sbr/strindex.h"
 #include "sbr/getarguments.h"
 #include "sbr/smatch.h"
 #include "sbr/strindex.h"
-#include "sbr/closefds.h"
 #include "sbr/trimcpy.h"
 #include "sbr/getcpy.h"
 #include "sbr/ambigsw.h"
 #include "sbr/trimcpy.h"
 #include "sbr/getcpy.h"
 #include "sbr/ambigsw.h"
@@ -1093,7 +1092,6 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress)
            }
            if (fd != 3)
                dup2 (fd, 3);
            }
            if (fd != 3)
                dup2 (fd, 3);
-           closefds (4);
 
 #ifdef TIOCNOTTY
            if ((fd = open ("/dev/tty", O_RDWR)) != -1) {
 
 #ifdef TIOCNOTTY
            if ((fd = open ("/dev/tty", O_RDWR)) != -1) {
index 945afbab753df9e8f053ad12c51bd83abf6efcc7..aa92aba63ff6d684a535a578b8f42c596ebfa607 100644 (file)
@@ -49,7 +49,6 @@
 #include "sbr/smatch.h"
 #include "sbr/r1bindex.h"
 #include "sbr/refile.h"
 #include "sbr/smatch.h"
 #include "sbr/r1bindex.h"
 #include "sbr/refile.h"
-#include "sbr/closefds.h"
 #include "sbr/copyip.h"
 #include "sbr/getcpy.h"
 #include "sbr/m_draft.h"
 #include "sbr/copyip.h"
 #include "sbr/getcpy.h"
 #include "sbr/m_draft.h"
@@ -1265,8 +1264,6 @@ sendit (char *sp, char **arg, char *file, int pushed)
     if ((pushsw = pushed))
        push ();
 
     if ((pushsw = pushed))
        push ();
 
-    closefds (3);
-
     if (sendsbr (vec, vecp, program, file, &st, 1, auth_svc) == OK)
        done (0);
 }
     if (sendsbr (vec, vecp, program, file, &st, 1, auth_svc) == OK)
        done (0);
 }
index ca94d3e17c0bc679fbee712e545450649d64fab3..7a74cf2b4314a53c620e69cad98475d03ac3a39d 100644 (file)
@@ -9,7 +9,6 @@
 #include "distsbr.h"
 #include "sbr/getarguments.h"
 #include "sbr/smatch.h"
 #include "distsbr.h"
 #include "sbr/getarguments.h"
 #include "sbr/smatch.h"
-#include "sbr/closefds.h"
 #include "sbr/m_draft.h"
 #include "sbr/context_find.h"
 #include "sbr/brkstring.h"
 #include "sbr/m_draft.h"
 #include "sbr/context_find.h"
 #include "sbr/brkstring.h"
@@ -190,8 +189,6 @@ main (int argc, char **argv)
     }
     vec[vecp] = NULL;
 
     }
     vec[vecp] = NULL;
 
-    closefds (3);
-
     if (distsw) {
         if ((child_id = fork()) == -1)
             adios("fork", "failed:");
     if (distsw) {
         if ((child_id = fork()) == -1)
             adios("fork", "failed:");