marlowabnp wrote:After some thought I think I know what the solution is. Process::kill should take a process handle. On UNIX it can use the process handle to get the pid and then kill by pid. On windoze it uses the WIN32 process handle directly, the one that was returned from the launch method.
Killing by pid on Unix will work in this case provided that the app that uses Poco::Process::launch does so in a dedicated thread. It can wait for the process to finish which it will if it is ever killed by someone/something else. The problem of pid reuse only applies if the app uses the pid to see (at regular intervals) if the process it launched is still alive. Therefore, what I said earlier about SIGCHLD does not apply. Pid reuse is only a problem for apps that do not wait for the child they spawned (in theory there is a small timing window between the spawn and the wait but I don't think there's anything that can be done about that and the window is tiny).
class Process: ...
PROC_LAUNCH_DETACHED = 0x01
static ProcessHandle launch(const std::string& command, const Args& args, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, int options = 0);
guenter wrote:I'm in favor of an overloaded kill() method in the Process class.
It would be great if you could implement this.
Users browsing this forum: No registered users and 2 guests