[systemd-commits] src/log.c src/main.c

Lennart Poettering lennart at kemper.freedesktop.org
Mon May 17 20:10:59 PDT 2010


 src/log.c  |    6 ++++--
 src/main.c |    2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

New commits:
commit c8513d54d23a36fc84b2f0b96989da3041ad15bc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue May 18 05:10:52 2010 +0200

    log: never close file descriptors < 3

diff --git a/src/log.c b/src/log.c
index 5d17955..7b4db4c 100644
--- a/src/log.c
+++ b/src/log.c
@@ -50,8 +50,10 @@ void log_close_console(void) {
         if (console_fd < 0)
                 return;
 
-        if (getpid() == 1 || console_fd != STDERR_FILENO) {
-                close_nointr_nofail(console_fd);
+        if (getpid() == 1) {
+                if (console_fd >= 3)
+                        close_nointr_nofail(console_fd);
+
                 console_fd = -1;
         }
 }
diff --git a/src/main.c b/src/main.c
index 311ece6..2e754fe 100644
--- a/src/main.c
+++ b/src/main.c
@@ -175,7 +175,7 @@ static void install_crash_handler(void) {
 static int make_null_stdio(void) {
         int null_fd, r;
 
-        if ((null_fd = open("/dev/null", O_RDWR)) < 0) {
+        if ((null_fd = open("/dev/null", O_RDWR|O_NOCTTY)) < 0) {
                 log_error("Failed to open /dev/null: %m");
                 return -errno;
         }


More information about the systemd-commits mailing list