Foreground mode works like daemon mode, except that it doesn't force logging to syslog, doesn't fork, and doesn't create a PID file. It is meant for use with service managers that handle log redirection and process tracking automatically, such as systemd.
The double forking used in daemon mode does not follow the forking completion protocol in systemd, which expects the PID file to be written and the main process to be running after the first fork, not the second. This can cause the service to fail when systemd can't find the PID file after the first fork. Not forking at all and using the exec completion protocol instead is simpler and less error-prone, as it lets systemd track the main process directly.
Foreground mode works like daemon mode, except that it doesn't force logging to syslog, doesn't fork, and doesn't create a PID file. It is meant for use with service managers that handle log redirection and process tracking automatically, such as systemd.
The double forking used in daemon mode does not follow the forking completion protocol in systemd, which expects the PID file to be written and the main process to be running after the first fork, not the second. This can cause the service to fail when systemd can't find the PID file after the first fork. Not forking at all and using the exec completion protocol instead is simpler and less error-prone, as it lets systemd track the main process directly.