]> git.wh0rd.org Git - patches.git/blob - udhcp-close-fds.patch
more random patches. who knows.
[patches.git] / udhcp-close-fds.patch
1 Index: signalpipe.c
2 ===================================================================
3 --- signalpipe.c        (revision 14725)
4 +++ signalpipe.c        (working copy)
5 @@ -20,6 +20,7 @@
6   */
7  
8  #include <unistd.h>
9 +#include <fcntl.h>
10  #include <signal.h>
11  #include <sys/types.h>
12  #include <sys/socket.h>
13 @@ -43,6 +44,8 @@ static void signal_handler(int sig)
14  void udhcp_sp_setup(void)
15  {
16         socketpair(AF_UNIX, SOCK_STREAM, 0, signal_pipe);
17 +       fcntl(signal_pipe[0], F_SETFD, FD_CLOEXEC);
18 +       fcntl(signal_pipe[1], F_SETFD, FD_CLOEXEC);
19         signal(SIGUSR1, signal_handler);
20         signal(SIGUSR2, signal_handler);
21         signal(SIGTERM, signal_handler);
22 @@ -56,7 +59,10 @@ int udhcp_sp_fd_set(fd_set *rfds, int ex
23  {
24         FD_ZERO(rfds);
25         FD_SET(signal_pipe[0], rfds);
26 -       if (extra_fd >= 0) FD_SET(extra_fd, rfds);
27 +       if (extra_fd >= 0) {
28 +               fcntl(extra_fd, F_SETFD, FD_CLOEXEC);
29 +               FD_SET(extra_fd, rfds);
30 +       }
31         return signal_pipe[0] > extra_fd ? signal_pipe[0] : extra_fd;
32  }
33