Closed cmaughan closed 3 years ago
Replace the noop with reproc::stop::wait
. Waiting 0 milliseconds is equivalent to just checking if the process is still running.
Thanks for the quick response ;) So what does the noop mean?
To do absolutely nothing at all. stop_actions
is a struct with three members but it's not required to supply three actions. Sometimes a single action is sufficient so we need an action to indicate that nothing should happen which is noop
. Usually you don't specify it explicitly as noop
is the default action.
For example:
reproc::stop_actions stop = {
{ reproc::stop::terminate, reproc::milliseconds(5000) },
{ reproc::stop::kill, reproc::milliseconds(2000) },
{}
};
The last action is not necessary so we just default initialize it which corresponds to the noop action as it is the first member of the stop enum.
OK, that's great, and makes perfect sense. Thanks.
I enabled Github Discussions for reproc, please post any further questions on using reproc there
Will do, thanks for the help :)
If I have a process that I suspect has already exited, but want to kill it if not, is this the right sequence? i.e. Is the noop the 'exit' if already exited part? Followed by terminate and kill?
It wasn't clear to me from the examples the correct approach here. The scenario is a process that has been running for a while, but has been asked to exit by another mechanism (it has received a network message, for example). So I 'hope' that it has already gone, but if not, I wish to close it.