Home:ALL Converter>Detect if dotnet core app on Linux run as systemd

Detect if dotnet core app on Linux run as systemd

Ask Time:2022-11-18T16:20:42         Author:Ye Rac

Json Formatter

i want to detect if my app (dotnet core 6.0 console) on Linux (Raspibian OS) is running as systemd. Reason is that my app is using OpenCV and it can, if configured, show live video. But if someone forget to set this configuration properly, and app want to show live video when running as systemd, it crashes.

Can someone give me a tip how to do this?

I have found on MSDN this: Console.WriteLine("UserInteractive: {0}", Environment.UserInteractive); but it doesn't work for Linux.

Author:Ye Rac,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/74486739/detect-if-dotnet-core-app-on-linux-run-as-systemd
yy