chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
core: inherit TERM from PID 1 for all services started on /dev/console
[elogind.git]
/
src
/
basic
/
terminal-util.c
diff --git
a/src/basic/terminal-util.c
b/src/basic/terminal-util.c
index fa4f60826c9821b3f26f87ac2c6a355fde8ade02..0f2cde00617b613ebdcc9cc38902a10424084366 100644
(file)
--- a/
src/basic/terminal-util.c
+++ b/
src/basic/terminal-util.c
@@
-792,7
+792,7
@@
bool tty_is_vc_resolve(const char *tty) {
}
const char *default_term_for_tty(const char *tty) {
}
const char *default_term_for_tty(const char *tty) {
- return tty && tty_is_vc_resolve(tty) ? "
TERM=linux" : "TERM=
vt220";
+ return tty && tty_is_vc_resolve(tty) ? "
linux" : "
vt220";
}
#endif // 0
}
#endif // 0
@@
-898,9
+898,7
@@
int make_stdio(int fd) {
/* Explicitly unset O_CLOEXEC, since if fd was < 3, then
* dup2() was a NOP and the bit hence possibly set. */
/* Explicitly unset O_CLOEXEC, since if fd was < 3, then
* dup2() was a NOP and the bit hence possibly set. */
- fd_cloexec(STDIN_FILENO, false);
- fd_cloexec(STDOUT_FILENO, false);
- fd_cloexec(STDERR_FILENO, false);
+ stdio_unset_cloexec();
return 0;
}
return 0;
}
@@
-1205,6
+1203,19
@@
int open_terminal_in_namespace(pid_t pid, const char *name, int mode) {
}
#endif // 0
}
#endif // 0
+bool terminal_is_dumb(void) {
+ const char *e;
+
+ if (!on_tty())
+ return true;
+
+ e = getenv("TERM");
+ if (!e)
+ return true;
+
+ return streq(e, "dumb");
+}
+
bool colors_enabled(void) {
static int enabled = -1;
bool colors_enabled(void) {
static int enabled = -1;
@@
-1214,10
+1225,8
@@
bool colors_enabled(void) {
colors = getenv("SYSTEMD_COLORS");
if (colors)
enabled = parse_boolean(colors) != 0;
colors = getenv("SYSTEMD_COLORS");
if (colors)
enabled = parse_boolean(colors) != 0;
- else if (streq_ptr(getenv("TERM"), "dumb"))
- enabled = false;
else
else
- enabled =
on_tty
();
+ enabled =
!terminal_is_dumb
();
}
return enabled;
}
return enabled;