chiark / gitweb /
execute: reopen console in the spawned processes, if necessary
authorLennart Poettering <lennart@poettering.net>
Wed, 19 May 2010 23:08:13 +0000 (01:08 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 19 May 2010 23:08:13 +0000 (01:08 +0200)
fixme
src/execute.c
src/service.c

diff --git a/fixme b/fixme
index 0894c4701d175b6ff769542ab3784eaaf04a4393..0c04ab8fe4aa9caa036223681586c02f287a723a 100644 (file)
--- a/fixme
+++ b/fixme
@@ -9,6 +9,9 @@
 * implicitly import "defaults" settings file into all types
 
 * write .service file install tool
+    [Install]
+    WantedBy=graphical.target
+    Names=prefdm.service
 
 * service startup should be delayed if the matching socket is being started
 
 
 * bootchart hookup
 
-* dbus.service and syslog.service should be symlinked not ifdef to the right distro-specific names
-
 * reinvestigate random seed, hwclock
 
-* rework sysv stuff to have SPECIAL_SYSV_BEFORE, SPECIAL_SYSV_AFTER instead SPECIAL_RCSYSINIT
-
 * introduce serialized mode
 
-* when refusing start due to ratelimit, enter restart state
-
 * "disabled" load state?
 
 * uid are 32bit
@@ -38,8 +35,6 @@
 
 * iCalendar semantics for the timer stuff (RFC2445)
 
-* autofs für /dev/mqueue usw.
-
 * provide sysv-like command line utilities
 
 * Add OnlyByDependency
index f3cf0261568377b9bce62c620eef015aaf909c25..53f6d9ad06dcaf8169ef825278bae2753ebaae46 100644 (file)
@@ -301,10 +301,15 @@ static int setup_output(const ExecContext *context, int socket_fd, const char *i
         case EXEC_OUTPUT_INHERIT:
 
                 /* If the input is connected to a terminal, inherit that... */
-                if (is_terminal_input(i) || i == EXEC_INPUT_SOCKET)
+                if (i != EXEC_INPUT_NULL)
                         return dup2(STDIN_FILENO, STDOUT_FILENO) < 0 ? -errno : STDOUT_FILENO;
 
-                return STDIN_FILENO;
+                /* For PID 1 stdout is always connected to /dev/null,
+                 * hence reopen the console if necessary. */
+                if (getpid() == 1)
+                        return open_terminal_as(tty_path(context), O_WRONLY, STDOUT_FILENO);
+
+                return STDOUT_FILENO;
 
         case EXEC_OUTPUT_NULL:
                 return open_null_as(O_WRONLY, STDOUT_FILENO);
@@ -346,7 +351,8 @@ static int setup_error(const ExecContext *context, int socket_fd, const char *id
          * the way and are not on a tty */
         if (e == EXEC_OUTPUT_INHERIT &&
             o == EXEC_OUTPUT_INHERIT &&
-            !is_terminal_input(i))
+            i != EXEC_INPUT_NULL &&
+            getpid () != 1)
                 return STDERR_FILENO;
 
         /* Duplicate form stdout if possible */
@@ -1076,11 +1082,6 @@ void exec_context_init(ExecContext *c) {
         c->cpu_sched_policy = SCHED_OTHER;
         c->syslog_priority = LOG_DAEMON|LOG_INFO;
         c->mount_flags = MS_SHARED;
-
-        c->std_input = EXEC_INPUT_NULL;
-        c->std_output = c->std_error =
-                (log_get_target() == LOG_TARGET_CONSOLE ? EXEC_OUTPUT_INHERIT :
-                 log_get_target() == LOG_TARGET_KMSG ? EXEC_OUTPUT_KMSG : EXEC_OUTPUT_SYSLOG);
 }
 
 void exec_context_done(ExecContext *c) {
index 2fcb304e86d7bffbcfae02627e6f5a842687d19b..3e2a499ec86bc73554672e02e3e789d6863cb46e 100644 (file)
@@ -632,11 +632,6 @@ static int service_load_sysv_path(Service *s, const char *path) {
         s->valid_no_process = true;
         s->kill_mode = KILL_PROCESS_GROUP;
 
-        /* For SysV services log output should go to the console */
-        s->exec_context.std_input = EXEC_INPUT_NULL;
-        s->exec_context.std_output = EXEC_OUTPUT_TTY;
-        s->exec_context.std_error = EXEC_OUTPUT_TTY;
-
         u->meta.load_state = UNIT_LOADED;
         r = 0;