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.
System and Service Manager
Details
Most documentation is available on systemd's web site.
Assorted, older, general information about systemd can be found in the systemd Wiki.
Information about build requirements is provided in the README file.
Consult our NEWS file for information about what's new in the most recent systemd versions.
Please see the Code Map for information about this repository's layout and content.
Please see the Hacking guide for information on how to hack on systemd and test your modifications.
Please see our Contribution Guidelines for more information about filing GitHub Issues and posting GitHub Pull Requests.
When preparing patches for systemd, please follow our Coding Style Guidelines.
If you are looking for support, please contact our mailing list, join our IRC channel #systemd on libera.chat or Matrix channel
Stable branches with backported patches are available in the stable repo.
We have a security bug bounty program sponsored by the Sovereign Tech Fund hosted on YesWeHack
Repositories with distribution packages built from git main are available on OBS
