question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UseSystemd can detect an interactive shell as `running as systemd service`

See original GitHub issue

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
…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
analogrelaycommented, Dec 5, 2019

This feels patch worthy…

There’s a clear workaround here though, which is to have your own conditional logic prior to calling UseSystemd. Generally that means it wouldn’t meet the bar (especially given that it does have a breaking change angle).

1reaction
analogrelaycommented, Dec 12, 2019

We don’t have a Systemd doc that I can find.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between systemd and terminal starting program
Use systemctl show your-unit-unit.service to check the full configuration values affecting the service you attempting to start. Non-interactive ...
Read more >
Interacting with a program running as part of a systemd ...
When the program is started, it provides a command line interface to allow interaction. However, as this program is run by systemd, I...
Read more >
systemd-run
In this mode, systemd-run will start the service asynchronously in the background and return after the command has begun execution (unless --no-block or...
Read more >
notification - How to use systemd notify
The systemd-notify tool is specifically meant to be used by a shell that runs as a systemd service using Type=notify .
Read more >
Using systemd to execute an interactive (whiptail) script ...
It runs agetty as a daemon to provide the login sessions on ... Have a look in /usr/lib/systemd/system/getty@.service to see them in use....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found