chiark / gitweb /
time: time_t is signed, and mktime() is happy to return negative time
[elogind.git] / src / shared / pager.c
index 82bca83f576ff30b4bceccbde4312d404ef90c2a..184a0f57846dcb520ed79cd6fec9adc93bcafa36 100644 (file)
@@ -36,6 +36,7 @@
 #include "process-util.h"
 #include "signal-util.h"
 #include "string-util.h"
+#include "strv.h"
 #include "terminal-util.h"
 
 static pid_t pager_pid = 0;
@@ -63,7 +64,7 @@ int pager_open(bool no_pager, bool jump_to_end) {
         if (pager_pid > 0)
                 return 1;
 
-        if (!on_tty())
+        if (terminal_is_dumb())
                 return 0;
 
         pager = getenv("SYSTEMD_PAGER");
@@ -71,7 +72,7 @@ int pager_open(bool no_pager, bool jump_to_end) {
                 pager = getenv("PAGER");
 
         /* If the pager is explicitly turned off, honour it */
-        if (pager && (pager[0] == 0 || streq(pager, "cat")))
+        if (pager && STR_IN_SET(pager, "", "cat"))
                 return 0;
 
         /* Determine and cache number of columns before we spawn the
@@ -158,8 +159,13 @@ void pager_close(void) {
                 return;
 
         /* Inform pager that we are done */
+#ifdef __GLIBC__
         stdout = safe_fclose(stdout);
         stderr = safe_fclose(stderr);
+#else
+        safe_fclose(stdout);
+        safe_fclose(stderr);
+#endif // __GLIBC__
 
         (void) kill(pager_pid, SIGCONT);
         (void) wait_for_terminate(pager_pid, NULL);