]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: close stdin/out/err in non-terminal case
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 3 Aug 2017 01:37:37 +0000 (03:37 +0200)
committerDavid Lamparter <equinox@opensourcerouting.org>
Thu, 3 Aug 2017 01:37:37 +0000 (03:37 +0200)
Oops, forgot this path... in the --terminal case, stdio is closed when
the user ends the terminal session, but without terminal it was left
open.

(This caused a ssh session hang in the CentOS6 CI because the file
descriptors were still open, so ssh would keep the session alive...)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/libfrr.c

index 55d77847524cc65835f3c9c4487c85aad9b8a09d..aa21a143bae95d8804356e811b586507e5a292fe 100644 (file)
@@ -688,8 +688,15 @@ void frr_run(struct thread_master *master)
                        thread_add_read(master, frr_daemon_ctl, NULL,
                                        daemon_ctl_sock, &daemon_ctl_thread);
                }
-       } else if (daemon_ctl_sock != -1) {
-               close(daemon_ctl_sock);
+       } else {
+               int nullfd = open("/dev/null", O_RDONLY | O_NOCTTY);
+               dup2(nullfd, 0);
+               dup2(nullfd, 1);
+               dup2(nullfd, 2);
+               close(nullfd);
+
+               if (daemon_ctl_sock != -1)
+                       close(daemon_ctl_sock);
                daemon_ctl_sock = -1;
        }