[…] an external command-line program. […]
Do you have control over this program? Because some applications use the pidfile pattern, i.e. the program (usually some kind of daemon) writes its PID to a known location (and later deletes the pidfile).
If by "control" you mean 'I started it running', then yes. If you mean 'I am the super-user monitoring and controlling all functions of this particular piece of kit', then no, that's why I wrote a GUI to interface with it.
Either way, I must apologize for my naïve assumption that when a file shows up via 'ps -A' with a certain PID, that PID is stuck with it for life. By "life" I mean "since the last time it was started". Some folks apparently think it means something different. Reading around the interwebs, it would seem that PID associations are as ephemeral as mayflies. In common practice though, I have found 'ps' proven itself reliable enough that a 'kill' command to take down a wayward bit of software via its reported PID will do
exactly what it says on the tin, fringe cases be damned.
And with that, I must get back to my previously scheduled programming...