[ovs-dev] [PATCH 02/13] daemon-unix: With --monitor, only close standard fds if --detach also used.

Ben Pfaff blp at ovn.org
Sat Oct 7 00:44:47 UTC 2017


Daemons generally should close the standard fds because they don't want to
hold open an SSH session, etc. that is attached to a tty.  But --monitor
without --detach does not daemonize, so do not close fds in that case.

Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/daemon-unix.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c
index 839114f3edf3..967a2843251f 100644
--- a/lib/daemon-unix.c
+++ b/lib/daemon-unix.c
@@ -472,7 +472,9 @@ daemonize_start(bool access_datapath)
         if (daemon_pid > 0) {
             /* Running in monitor process. */
             fork_notify_startup(saved_daemonize_fd);
-            close_standard_fds();
+            if (detach) {
+                close_standard_fds();
+            }
             monitor_daemon(daemon_pid);
         }
         /* Running in daemon process. */
-- 
2.10.2



More information about the dev mailing list