]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: spawn pager only for commands that generates long output
authorLennart Poettering <lennart@poettering.net>
Tue, 4 Jan 2011 00:04:20 +0000 (01:04 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 4 Jan 2011 00:04:20 +0000 (01:04 +0100)
src/systemctl.c

index 59ea7490e767dfa879e3673a7875a9d4b2654e77..0908b6ae02e69304493135f93d6210c18d43804c 100644 (file)
@@ -113,6 +113,7 @@ static bool private_bus = false;
 static pid_t pager_pid = 0;
 
 static int daemon_reload(DBusConnection *bus, char **args, unsigned n);
+static void pager_open(void);
 
 static bool on_tty(void) {
         static int t = -1;
@@ -421,6 +422,8 @@ static int list_units(DBusConnection *bus, char **args, unsigned n) {
 
         assert(bus);
 
+        pager_open();
+
         if (!(m = dbus_message_new_method_call(
                               "org.freedesktop.systemd1",
                               "/org/freedesktop/systemd1",
@@ -767,6 +770,8 @@ static int list_jobs(DBusConnection *bus, char **args, unsigned n) {
 
         assert(bus);
 
+        pager_open();
+
         if (!(m = dbus_message_new_method_call(
                               "org.freedesktop.systemd1",
                               "/org/freedesktop/systemd1",
@@ -2477,6 +2482,9 @@ static int show(DBusConnection *bus, char **args, unsigned n) {
 
         show_properties = !streq(args[0], "status");
 
+        if (show_properties)
+                pager_open();
+
         if (show_properties && n <= 1) {
                 /* If not argument is specified inspect the manager
                  * itself */
@@ -2860,6 +2868,8 @@ static int dump(DBusConnection *bus, char **args, unsigned n) {
 
         dbus_error_init(&error);
 
+        pager_open();
+
         if (!(m = dbus_message_new_method_call(
                               "org.freedesktop.systemd1",
                               "/org/freedesktop/systemd1",
@@ -3222,6 +3232,8 @@ static int show_enviroment(DBusConnection *bus, char **args, unsigned n) {
 
         dbus_error_init(&error);
 
+        pager_open();
+
         if (!(m = dbus_message_new_method_call(
                               "org.freedesktop.systemd1",
                               "/org/freedesktop/systemd1",
@@ -5370,8 +5382,6 @@ int main(int argc, char*argv[]) {
                 goto finish;
         }
 
-        pager_open();
-
         /* /sbin/runlevel doesn't need to communicate via D-Bus, so
          * let's shortcut this */
         if (arg_action == ACTION_RUNLEVEL) {