diff --git a/CHANGELOG.md b/CHANGELOG.md index afc0bd77..86006ced 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - `[initsystem/sdnotify]` Added new package for sending messages to systemd - `[support/deps]` Updated for compatibility with the latest version of [depsy](https://kaos.sh/depsy) +- `[terminal/tty]` Improved check for systemd ### 12.120.0 diff --git a/terminal/tty/tty_posix.go b/terminal/tty/tty_posix.go index f3adb6c7..f25174b8 100644 --- a/terminal/tty/tty_posix.go +++ b/terminal/tty/tty_posix.go @@ -46,8 +46,7 @@ func IsFakeTTY() bool { // IsSystemd returns true if process started by systemd func IsSystemd() bool { - return os.Getenv("INVOCATION_ID") != "" || - os.Getenv("SYSTEMCTL_IGNORE_DEPENDENCIES") != "" + return os.Getppid() == 1 } // ////////////////////////////////////////////////////////////////////////////////// // diff --git a/terminal/tty/tty_test.go b/terminal/tty/tty_test.go index 28e22c94..27e3c975 100644 --- a/terminal/tty/tty_test.go +++ b/terminal/tty/tty_test.go @@ -48,12 +48,7 @@ func (s *TTYSuite) TestIsTTY(c *C) { } func (s *TTYSuite) TestIsSystemd(c *C) { - os.Setenv("INVOCATION_ID", "") - os.Setenv("SYSTEMCTL_IGNORE_DEPENDENCIES", "") - c.Assert(IsSystemd(), Equals, false) - os.Setenv("INVOCATION_ID", "5d0149bfa2c34b79bccb13074001eb20") - c.Assert(IsSystemd(), Equals, true) - os.Setenv("INVOCATION_ID", "") + IsSystemd() } func (s *TTYSuite) TestIsTMUX(c *C) {