chiark / gitweb /
log: never close file descriptors < 3
authorLennart Poettering <lennart@poettering.net>
Tue, 18 May 2010 03:10:52 +0000 (05:10 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 18 May 2010 03:10:52 +0000 (05:10 +0200)
src/log.c
src/main.c

index 5d17955e7ebbd9ddb25a933b8faebac4192bb9fe..7b4db4c77a4134f78a7ecd657637248a06049e40 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -50,8 +50,10 @@ void log_close_console(void) {
         if (console_fd < 0)
                 return;
 
         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;
         }
 }
                 console_fd = -1;
         }
 }
index 311ece6b57141cdf8be5cc1d4f1cbceea5f76342..2e754fe6e0fa62680db690b1946fc14b1ad9ff5b 100644 (file)
@@ -175,7 +175,7 @@ static void install_crash_handler(void) {
 static int make_null_stdio(void) {
         int null_fd, r;
 
 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;
         }
                 log_error("Failed to open /dev/null: %m");
                 return -errno;
         }