1. 6
  1.  

  2. 3

    Perhaps PID is the wrong mechanism to talk to a daemon. There’s a mention of control sockets, but not really as a replacement for PIDs entirely. Have each process listen on /var/run/daemon-ctl and you can talk to it without knowing the PID.

    1. 2

      It’s not about talking to a daemon. Init system has to keep track of PID so it can catch when the daemon dies. All my services have Restart=always, which means systemd should start it again if the process dies for whatever reason (other than being explicitly stopped with systemctl).

      1. 2

        Which it does by …? Polling the system to see which PIDs are alive? At that point, may as well just poll by trying to connect to the control socket.

        1. 2

          By virtue of being PID 1, it’ll get a SIGCHLD every time an orphan process (which should be every daemon) dies. That’s the main reason to want your service manager to run in PID 1, really.

          PID/signaling is definitely not the right way to talk to a daemon, though.

          1. 3

            Oh, ok. I think I’m slow to realize init and the service manager would be the same process. That was probably the point of the article. Oops.

      2. 2

        That becomes complicated quickly, once you run multiple instances of the same daemon.