mirror of
https://github.com/systemd/systemd.git
synced 2026-08-04 15:10:33 +00:00
core: use terminal DCS sequence to set $TERM
query_term_for_tty() is used in two places: in fixup_environment(), which affects PID1 itself, and in build_environment(), which affects spawned services. There is obviously some cost to the extra call, but I think it's worthwhile to do it. When $TERM is set incorrectly, basic output works OK, but then there are various annoying corner cases. In particular, we get the support for color (or lack of it) wrong, and when output is garbled, users are annoyed. Things like text editors are almost certain to behave incorrectly. Testing in test-terminal-util indicates that the time required to make a successful query is on the order of a dozen microseconds, and an unsuccessful query costs as much as our timeout, i.e. currently 1/3 ms. I think this is an acceptable tradeoff. No caching is used, because fixup_environment() is only called once, and the other place in build_environment(), only affects services which are connected to a tty, which is only a handful of services, and often only started in special circumstances. Fixes https://github.com/systemd/systemd/issues/36994.
This commit is contained in:
@@ -143,6 +143,9 @@ assert_cc((TTY_MODE & 0711) == 0600);
|
||||
|
||||
void termios_disable_echo(struct termios *termios);
|
||||
|
||||
/* The $TERM value we use for terminals other than the Linux console */
|
||||
#define FALLBACK_TERM "vt220"
|
||||
|
||||
int get_default_background_color(double *ret_red, double *ret_green, double *ret_blue);
|
||||
int terminal_get_size_by_dsr(int input_fd, int output_fd, unsigned *ret_rows, unsigned *ret_columns);
|
||||
int terminal_fix_size(int input_fd, int output_fd);
|
||||
|
||||
Reference in New Issue
Block a user