pkg/pidfile: Write(): take pid as argument

This allows it to be used for processes other than the daemon itself.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2022-10-15 16:52:30 +02:00
parent 735e250326
commit 81945da0ac
3 changed files with 17 additions and 5 deletions

View File

@@ -139,7 +139,7 @@ func (cli *DaemonCli) start(opts *daemonOptions) (err error) {
potentiallyUnderRuntimeDir := []string{cli.Config.ExecRoot}
if cli.Pidfile != "" {
if err := pidfile.Write(cli.Pidfile); err != nil {
if err = pidfile.Write(cli.Pidfile, os.Getpid()); err != nil {
return errors.Wrap(err, "failed to start daemon")
}
potentiallyUnderRuntimeDir = append(potentiallyUnderRuntimeDir, cli.Pidfile)