Commonly a long running program will have it's pid saved in a file. This is not reliable as the pid will be reused by other programs if the original program exits. I think also the program can modify its /proc/cmdline and other pgreppable features.
What is a reliable way to store a handle to the program to facilitate later KILL or other interaction?
I think if the parent of the original program stays alive, it can rely on the pid being correct, because the pid will not be re-used until the parent wait(2)s. Perhaps this could be used by having a wrapper parent that only starts the subprocess and manages the child pid file.
Is there a robust implementation of this parent solution?
Is there a solution without relying on the parent staying alive?