X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Fterminal-util.c;h=efd35cd727cc944c166f428c113669ff97d975c6;hp=59fac9c0c2ab361f486e00ce94f60076d435c519;hb=d5949929f1247b0407637a44f388365e3966ef91;hpb=0801458c689ba85fd27666f69e42818f87353bc2 diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c index 59fac9c0c..efd35cd72 100644 --- a/src/basic/terminal-util.c +++ b/src/basic/terminal-util.c @@ -347,12 +347,7 @@ int open_terminal(const char *name, int mode) { } r = isatty(fd); - if (r < 0) { - safe_close(fd); - return -errno; - } - - if (!r) { + if (r == 0) { safe_close(fd); return -ENOTTY; } @@ -1224,11 +1219,11 @@ bool colors_enabled(void) { static int enabled = -1; if (_unlikely_(enabled < 0)) { - const char *colors; + int val; - colors = getenv("SYSTEMD_COLORS"); - if (colors) - enabled = parse_boolean(colors) != 0; + val = getenv_bool("SYSTEMD_COLORS"); + if (val >= 0) + enabled = val; else if (getpid() == 1) /* PID1 outputs to the console without holding it open all the time */ enabled = !getenv_terminal_is_dumb();