chiark / gitweb /
systemctl: append .service to unit names lacking suffix
[elogind.git] / src / shared / pager.c
index 3fc81820e9b4de7444658197cb98bb7ee3858c9d..36b409c07031932843c5994209d8daa3bed44fc9 100644 (file)
@@ -6,16 +6,16 @@
   Copyright 2010 Lennart Poettering
 
   systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
+  under the terms of the GNU Lesser General Public License as published by
+  the Free Software Foundation; either version 2.1 of the License, or
   (at your option) any later version.
 
   systemd is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  General Public License for more details.
+  Lesser General Public License for more details.
 
-  You should have received a copy of the GNU General Public License
+  You should have received a copy of the GNU Lesser General Public License
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
@@ -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) {