[systemd-commits] 2 commits - src/journal src/shared src/systemctl

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Mon Jul 23 09:27:05 PDT 2012


 src/journal/journalctl.c  |    6 +-----
 src/shared/pager.c        |   17 ++++++++++-------
 src/shared/pager.h        |    4 +++-
 src/systemctl/systemctl.c |    2 +-
 4 files changed, 15 insertions(+), 14 deletions(-)

New commits:
commit 81cf1c43c9a24834433bb5c1f0dc6eb3c1c5b44f
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Mon Jul 23 18:26:31 2012 +0200

    systemctl: use color specification understood by dot
    
    grey66 is aproximately equal to dark grey. Not understanding dark grey is really
    a bug in dot, but trivial to work around.
    
    Closes https://bugs.freedesktop.org/show_bug.cgi?id=45706

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 18c8abe..a13fc1a 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -783,7 +783,7 @@ static int dot_one_property(const char *name, const char *prop, DBusMessageIter
                 "RequiresOverridable",   "[color=\"black\"]",
                 "Requisite",             "[color=\"darkblue\"]",
                 "RequisiteOverridable",  "[color=\"darkblue\"]",
-                "Wants",                 "[color=\"darkgrey\"]",
+                "Wants",                 "[color=\"grey66\"]",
                 "Conflicts",             "[color=\"red\"]",
                 "ConflictedBy",          "[color=\"red\"]",
                 "After",                 "[color=\"green\"]"

commit fafb6eccc2c9e3f8d6ce0aad9cb428f8cc402b24
Author: Zbigniew Jedrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Jul 20 09:06:26 2012 +0200

    journalctl: fix ellipsization with PAGER=cat
    
    There are other reasons for not opening the pager then the --no-pager
    or --follow options (described below). If the pager is not used,
    messages must be ellipsized.
    
    On Fri, Jul 20, 2012 at 05:42:44AM +0000, Shawn Landen wrote:
    > "Pager to use when --no-pager is not given; overrides $PAGER.
    > Setting this to an empty string or the value cat is equivalent to passing --no-pager."

diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index e9810c9..e633dd3 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -398,11 +398,7 @@ int main(int argc, char *argv[]) {
                 goto finish;
         }
 
-        have_pager = !arg_no_pager && !arg_follow;
-        if (have_pager) {
-                columns();
-                pager_open();
-        }
+        have_pager = !arg_no_pager && !arg_follow && pager_open();
 
         if (arg_output == OUTPUT_JSON) {
                 fputc('[', stdout);
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 6a85af3..36b409c 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -44,20 +44,20 @@ _noreturn_ static void pager_fallback(void) {
         _exit(EXIT_SUCCESS);
 }
 
-void pager_open(void) {
+bool pager_open(void) {
         int fd[2];
         const char *pager;
         pid_t parent_pid;
 
         if (pager_pid > 0)
-                return;
+                return false;
 
         if ((pager = getenv("SYSTEMD_PAGER")) || (pager = getenv("PAGER")))
                 if (!*pager || streq(pager, "cat"))
-                        return;
+                        return false;
 
         if (isatty(STDOUT_FILENO) <= 0)
-                return;
+                return false;
 
         /* Determine and cache number of columns before we spawn the
          * pager so that we get the value from the actual tty */
@@ -65,7 +65,7 @@ void pager_open(void) {
 
         if (pipe(fd) < 0) {
                 log_error("Failed to create pager pipe: %m");
-                return;
+                return false;
         }
 
         parent_pid = getpid();
@@ -74,7 +74,7 @@ void pager_open(void) {
         if (pager_pid < 0) {
                 log_error("Failed to fork pager: %m");
                 close_pipe(fd);
-                return;
+                return false;
         }
 
         /* In the child start the pager */
@@ -115,10 +115,13 @@ void pager_open(void) {
         }
 
         /* Return in the parent */
-        if (dup2(fd[1], STDOUT_FILENO) < 0)
+        if (dup2(fd[1], STDOUT_FILENO) < 0) {
                 log_error("Failed to duplicate pager pipe: %m");
+                return false;
+        }
 
         close_pipe(fd);
+        return true;
 }
 
 void pager_close(void) {
diff --git a/src/shared/pager.h b/src/shared/pager.h
index dcd6195..0b4afc0 100644
--- a/src/shared/pager.h
+++ b/src/shared/pager.h
@@ -21,5 +21,7 @@
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-void pager_open(void);
+#include <stdbool.h>
+
+bool pager_open(void);
 void pager_close(void);



More information about the systemd-commits mailing list