commit:     06a6a27e441372164872c7712b80728527a6ec05
Author:     William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Sat Apr 29 15:12:16 2017 +0000
Commit:     William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Sat Apr 29 15:12:16 2017 +0000
URL:        https://gitweb.gentoo.org/proj/openrc.git/commit/?id=06a6a27e

supervise-daemon:  fix access to tty_fd and devnull_fd

Both the child and supervisor need access to these file descriptors.

 src/rc/supervise-daemon.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/rc/supervise-daemon.c b/src/rc/supervise-daemon.c
index 5636eaab..b13ec9e8 100644
--- a/src/rc/supervise-daemon.c
+++ b/src/rc/supervise-daemon.c
@@ -674,6 +674,10 @@ int main(int argc, char **argv)
        if (child_pid != 0)
                exit(EXIT_SUCCESS);
 
+#ifdef TIOCNOTTY
+       tty_fd = open("/dev/tty", O_RDWR);
+#endif
+       devnull_fd = open("/dev/null", O_RDWR);
        child_pid = fork();
        if (child_pid == -1)
                eerrorx("%s: fork: %s", applet, strerror(errno));
@@ -682,12 +686,6 @@ int main(int argc, char **argv)
                /* this is the supervisor */
                umask(numask);
 
-#ifdef TIOCNOTTY
-               tty_fd = open("/dev/tty", O_RDWR);
-#endif
-
-               devnull_fd = open("/dev/null", O_RDWR);
-
                fp = fopen(pidfile, "w");
                if (! fp)
                        eerrorx("%s: fopen `%s': %s", applet, pidfile, 
strerror(errno));

Reply via email to