When wxProcess::Kill() launches wxProcess::OnTerminate() ? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
DeeJay
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Sep 16, 2021 12:15 pm

When wxProcess::Kill() launches wxProcess::OnTerminate() ?

Post by DeeJay »

Hello,
I have ubuntu 20.04 OS with wxWidgets 3.0.5. I have a custom Process class (inherits from wxProcess) with OnTerminate() function overridden. When I kill a process associated with an instant of MyProcess class with MyProcess::Kill(), according to the documentation of the wxProcess::OnTerminate():

https://docs.wxwidgets.org/3.0/classwx_ ... 4cbb72a172

the OnTerminate() function should not be called. But in my case it is.

I want to know, if this should not happen at all - mistake is in my code, or if this is an expected behavior. If it is, then under which circumstances is the OnTerminate() launched, when the process is killed.

Additinal info:

I launch the command asynchronously with wxExecute("a.out", wxEXEC_ASYNC | wxEXEC_MAKE_GROUP_LEADER, myProcess);

The program a.out has this implementation:

Code: Select all

#include <iostream>

int main(int argc, char *argv[]){
    int k;
    
    std::cout << "Narg = " << argc - 1 << std::endl;
    for(k = 1; k < argc; ++k){
        std::cout << argv[k] << std::endl;
    }
    
    std::cerr << "Fail";
    
    while(true){

    }
    
    return 127;
}
The flag returned from MyProcess::Kill() function is wxKILL_OK.

Thanks
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: When wxProcess::Kill() launches wxProcess::OnTerminate() ?

Post by ONEEYEMAN »

Hi,
Did you try an :exec" sample?

Thank you.
DeeJay
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Sep 16, 2021 12:15 pm

Re: When wxProcess::Kill() launches wxProcess::OnTerminate() ?

Post by DeeJay »

Hi ONEEYEMAN,
thank you for your reply. No, I did not. I just skimmed it through to get to know, how to handle wxExecute(). If I understand it correctly - Do you suggest to launch the exec sample, try to kill processes with different signals and figure out, when the OnTerminate() is launched and when not? Or was it just a simple question and I am thinking too much :? ?

Thank you for your answer
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: When wxProcess::Kill() launches wxProcess::OnTerminate() ?

Post by ONEEYEMAN »

Hi,
What i mean is - build and run it on you binaries and see if the behaviour is the same.
Also check the docs as appropriate.

Thank you.
.
DeeJay
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Sep 16, 2021 12:15 pm

Re: When wxProcess::Kill() launches wxProcess::OnTerminate() ?

Post by DeeJay »

Thanks, I will try this.

I have checked the doc:

https://docs.wxwidgets.org/3.0/classwx_ ... 4cbb72a172

see the original post. It says (in doc of wxProcess::OnTerminate())
Note that this function won't be called if you Kill() the process.
The opposite happens in my case.

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: When wxProcess::Kill() launches wxProcess::OnTerminate() ?

Post by doublemax »

Try asking again on the wx-users Google group / mailing list where you can reach the core wx developers. This here is a user forum.
https://groups.google.com/g/wx-users
Use the source, Luke!
DeeJay
Knows some wx things
Knows some wx things
Posts: 27
Joined: Thu Sep 16, 2021 12:15 pm

Re: When wxProcess::Kill() launches wxProcess::OnTerminate() ?

Post by DeeJay »

Hello, thank you doublemax. I will repost this issue on the mailing list.
Post Reply