From: Ken Hornstein Date: Tue, 23 Apr 2019 00:36:14 +0000 (-0400) Subject: Garbage collect closefds() X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/b22bcbc2adddca14cc1889b1eee37643e0b88489?hp=fc42ab983b41f9c344e4cf330f5e525cb2792683 Garbage collect closefds() 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. --- diff --git a/Makefile.am b/Makefile.am index 9f6b675c..ed782681 100644 --- a/Makefile.am +++ b/Makefile.am @@ -361,7 +361,6 @@ noinst_HEADERS = \ sbr/brkstring.h \ sbr/check_charset.h \ sbr/client.h \ - sbr/closefds.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/closefds.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 index 49954827..00000000 --- a/sbr/closefds.c +++ /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 index 4bb77cfc..00000000 --- a/sbr/closefds.h +++ /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); diff --git a/uip/rcvtty.c b/uip/rcvtty.c index 73440fb0..c66f3996 100644 --- a/uip/rcvtty.c +++ b/uip/rcvtty.c @@ -15,7 +15,6 @@ #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" @@ -238,7 +237,6 @@ message_fd (char **vec) 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); diff --git a/uip/replsbr.c b/uip/replsbr.c index e3c88949..ed5e94ed 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -12,7 +12,6 @@ #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" @@ -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)); - closefds (3); /* * We're not allocating the memory for the extra arguments, diff --git a/uip/send.c b/uip/send.c index f29bb45f..d3fc4b1c 100644 --- a/uip/send.c +++ b/uip/send.c @@ -15,7 +15,6 @@ #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" @@ -483,7 +482,6 @@ go_to_it: push (); status = 0; - closefds (3); for (msgnum = 0; msgnum < msgp; msgnum++) { switch (sendsbr (vec, vecp, program, msgs[msgnum], &st, 1, auth_svc)) { diff --git a/uip/slocal.c b/uip/slocal.c index 5eb5243c..8cca5e35 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -26,7 +26,6 @@ #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" @@ -1093,7 +1092,6 @@ usr_pipe (int fd_arg, char *cmd, char *pgm, char **vec, int suppress) } if (fd != 3) dup2 (fd, 3); - closefds (4); #ifdef TIOCNOTTY if ((fd = open ("/dev/tty", O_RDWR)) != -1) { diff --git a/uip/whatnowsbr.c b/uip/whatnowsbr.c index 945afbab..aa92aba6 100644 --- a/uip/whatnowsbr.c +++ b/uip/whatnowsbr.c @@ -49,7 +49,6 @@ #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" @@ -1265,8 +1264,6 @@ sendit (char *sp, char **arg, char *file, int pushed) if ((pushsw = pushed)) push (); - closefds (3); - if (sendsbr (vec, vecp, program, file, &st, 1, auth_svc) == OK) done (0); } diff --git a/uip/whom.c b/uip/whom.c index ca94d3e1..7a74cf2b 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -9,7 +9,6 @@ #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" @@ -190,8 +189,6 @@ main (int argc, char **argv) } vec[vecp] = NULL; - closefds (3); - if (distsw) { if ((child_id = fork()) == -1) adios("fork", "failed:");