>_ IzzyLab

Topic breakdown

A PID is a process's unique numeric identifier; services write a pidfile (a file with that single number) so management systems know who to stop or restart. The task is to find the PID of the process listening on the required port and write it to the file. It can be found via listening sockets (ss with process display prints a pid=… chunk nearby) or via pgrep -f, which matches against the entire command line, including arguments like the port number. Critically: the pidfile must hold only an integer with no spaces or extra lines, and the PID's liveness is checked with signal 0 (kill -0).

What's checked

  1. the file /run/webapp.pid is created
  2. /run/webapp.pid holds the PID of the process on port 7777

What it looks like