Skip to content

UseSystemd can detect an interactive shell as running as systemd service #2525

@Tragetaschen

Description

@Tragetaschen

Describe the bug

I have my embedded platform and configure the IHostBuilder to .UseSystemd().

  1. Using the application as systemd service always works correctly.
  2. When I log into my system using SSH, I can run my application on the interactive prompt and it's using ConsoleLifetime and console logging format.
  3. When I use the tty on the serial port to run the application, that's detected as systemd environment and I get the systemd log format and termination behavior (no SIGINT handler)

The reason for the latter case is that my bash instance on the serial port inherits the INVOCATION_ID environment variable through login:

# env
LANG=C.UTF-8
OLDPWD=/
INVOCATION_ID=5561c5304f434119a45c4b6f260f1b00
EDITOR=vi
XDG_SESSION_ID=c1
HUSHLOGIN=FALSE
USER=root
PWD=/root
HOME=/root
JOURNAL_STREAM=8:13520
XDG_SESSION_TYPE=tty
MAIL=/var/spool/mail/root
SHELL=/bin/sh
TERM=putty
XDG_SESSION_CLASS=user
SHLVL=1
LOGNAME=root
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/0/bus
XDG_RUNTIME_DIR=/run/user/0
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
PS1=\u@\h:\w\$
_=/usr/bin/env
# pstree
systemd-+-…
        |-login---sh---pstree
…

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions