I am trying to write a routine that returns from a given PID path to its binary file or executable, depending on platform. I know it can be done on windows using windows.h, but that is platform dependent solution.
I was trying to find a solution using Qt, but I got nowhere near my goal, because there is no way to construct QProcess or any other class using provided PID.
But boost(v1.66) has a class boost::process::child, which can be constructed using provided PID, and can even return native handle (boost::process::child::native_handle_t). But from there I do not know.
It does not have any methods (which does not surprise, because it seems to be alias for void*), but I could not find any method extracting any information from this "class" either.
So is there a way to extract the information about location of the binary from a given PID using boost or there isn't ??
Draft of the function:
boost::filesystem::path GetExecutable (boost::process::pid_t pid) {
boost::filesystem::path path_to_executable;
bp::child process (pid);
boost::process::child::native_handle_t handle = process.native_handle();
.
.
.
return path_to_executable;
}