On 2020-08-21 09:38, Arjen de Korte via clamav-users wrote: >> >> However, systemd isn't the only service manager, and the problem still >> exists in all of the other ones. Systemd is able to avail itself of >> platform-specific features in brand-new Linux kernels. SysV init, >> OpenRC, and others must stick to real or de-facto standard tools, and >> there is no standard way to implement what systemd says they've done. > > That may be, but now you have replaced it with two processes that run > in the foreground, one of them as unpriviledged user and one as root > (probably to delete the PIDFile upon exit). I don't consider this > progress. >
The clamd process starts in the foreground, and then forks (a new process) to the background. The PID file should contain the PID of the forked process. No root process should be left running in the foreground; the service manager is in charge of cleaning up the file. >> >> That's fine, now you just need to synchronize the PIDFile and PidFile >> entries in your systemd service and clamd.conf, respectively. > > No, as stated before, systemd doesn't need the PIDFile at all. It > keeps track of the processes it started without the help of a PIDFile. > It *can* use a PIDFile if you provide it with one and the only thing > it will do with that is to remove that file if the service doesn't do > it itself upon exit. Nothing more, it is not used for process control. > There is absolutely no need for a PIDFile in the clamd.service, even > with Type=forking. Systemd tries to guess the PID file with Type=forking when you don't provide one (the GuessMainPID option). Either way, systemd does need to know the PID file's location -- the only question is whether or not it's able to guess. Something isn't working, so to rule some things out, it might help to point it at the PID file manually. >> Well empirically that's not true, because it isn't working. Add PIDFile >> entries to your service files when using Type=forking, and synchronize >> them with the PidFile lines in clamd.conf and freshclam.conf. > > Makes no difference at all. Even without using systemd, clamd doesn't > daemonize anymore, it will always run in the foreground. How long have you waited for clamd to start? With git head (and only official signatures), it takes about 25 seconds here: # time sbin/clamd real 0m25.409s user 0m0.005s sys 0m0.005s but after that the process does indeed fork into the background. If it doesn't, maybe we're looking in the wrong place. The PID file also points to the correct (forked) process in my case: # cat run/clamd.pid 7436 # ps ax | grep clamd 7436 ? Ssl 0:25 sbin/clamd _______________________________________________ clamav-users mailing list clamav-users@lists.clamav.net https://lists.clamav.net/mailman/listinfo/clamav-users Help us build a comprehensive ClamAV guide: https://github.com/vrtadmin/clamav-faq http://www.clamav.net/contact.html#ml