Interview Prep/Linux/Processes, services and systemd

An app forks into a background daemon itself. systemd thinks it died right after start. How do you configure the unit?

IntermediateScenarioProcesses, services and systemd
Answer

Situation read → Wrong service Type.

What I'd do →

  1. Best: run the app in the foreground (most have a --foreground or -D flag) and keep Type=simple or exec.
  2. If it must fork:
[Service]
Type=forking
PIDFile=/run/myapp/myapp.pid
ExecStart=/usr/sbin/myapp -d

Why → With Type=simple, the parent exits after forking and systemd considers the service stopped and may kill the child.

Interview tip → Mention Type=notify for apps that signal readiness with sd_notify.

All Linux questions Roadmap: Linux

More on Processes, services and systemd