Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

Cropi
Copy link
Member

@Cropi Cropi commented Sep 8, 2022

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.

forking mode

From the systemd.service man page: 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.
@Cropi Cropi merged commit 673431e into USBGuard:master Nov 16, 2022
@Cropi Cropi deleted the fork-race-condition branch November 16, 2022 07:45
@Cropi Cropi self-assigned this Dec 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant