[gnome-keyring] main: don't call close() with a negative value



commit 15ac2c4fbb68560844d0422c22e727cab8bb17ce
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Apr 26 10:35:10 2017 -0700

    main: don't call close() with a negative value
    
    When run_foreground = TRUE, fork_and_print_environment() will return -1,
    which is assigned to parent_wakeup_fd.
    Since we don't want to call close(-1), only close(parent_wakeup_fd) when
    run_foreground = FALSE.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=781785

 daemon/gkd-main.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/daemon/gkd-main.c b/daemon/gkd-main.c
index 57b72a0..f2c371f 100644
--- a/daemon/gkd-main.c
+++ b/daemon/gkd-main.c
@@ -1133,10 +1133,11 @@ main (int argc, char *argv[])
 
        /* Print the environment and tell the parent we're done */
        print_environment ();
-       close (parent_wakeup_fd);
 
-       if (!run_foreground)
+       if (!run_foreground) {
+               close (parent_wakeup_fd);
                redirect_fds_after_fork ();
+       }
 
        g_unix_signal_add (SIGTERM, on_signal_term, loop);
        g_unix_signal_add (SIGHUP, on_signal_term, loop);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]