USBGuard / usbguard

USBGuard is a software framework for implementing USB device authorization policies (what kind of USB devices are authorized) as well as method of use policies (how a USB device may interact with the system)
https://usbguard.github.io/
GNU General Public License v2.0
1.1k stars 133 forks source link

The parent process should wait for the first child process to finish in forking mode(-f) #554

Closed Cropi closed 1 year ago

Cropi commented 1 year ago

From the systemd.service man page regarding the Type= option:

      If set to forking, it is expected that the process configured with ExecStart= will call fork()
      as part of its start-up. The parent process is expected to exit when start-up is complete
      and all communication channels are set up. The child continues to run as the main service
      process, and the service manager will consider the unit started when the parent process
      exits. This is the behavior of traditional UNIX services. If this setting is used, it is
      recommended to also use the PIDFile= option, so that systemd can reliably identify the
      main process of the service. systemd will proceed with starting follow-up units as soon
      as the parent process exits.

With this in mind, the parent process should not exit until everything is fully initialized and the first child process exited. Otherwise, systemd could wrongly identify the PPID for the PID found in /run/usbguard.pid and due to this the following warning messages could be seen in the journal:

systemd: usbguard.service: Supervising process 1059 which is not our child. We'll most likely not notice when it exits.