Re: wxKill problem

16 views
Skip to first unread message

Vadim Zeitlin

unread,
Jun 20, 2007, 5:42:05 PM6/20/07
to wx-u...@lists.wxwidgets.org
On Wed, 20 Jun 2007 08:58:34 +0300 Eran Ifrah <eran....@gmail.com> wrote:

EI> I found out that a behavior which I am not sure is a bug in wxKill.
EI> According to the documentation, using the wxKILL_CHILDREN flag will kill the
EI> process, as well as its children.
EI> But what if these children have children too? in such case, my program
EI> leaves an orphan processes in the system.
EI>
EI> I think a new flag should be added wxKILL_TREE - this will kill the process
EI> tree and not just the direct children.

Could you please check if wxKILL_CHILDREN already behaves like this under
Unix? I think it should, in which case we don't need a new flag but just to
fix the existing code.

EI> The current implementation for windows, is doing the following logic:
EI> - take a snapshot of the system processes
EI> - iterate over the processes, each process that it parent process id matches
EI> the process we want to kill, kill it as well.
EI>
EI> To kill the process tree, another test should be added:
EI> - in every iteration, check not only against the process id we want to kill,
EI> but also against the child processes we already killed.

As usual, patches to implement this would be welcome (once the question
above is resolved).

Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/


Eran Ifrah

unread,
Jun 20, 2007, 3:49:30 PM6/20/07
to wx-u...@lists.wxwidgets.org
Hi,


I found out that a behavior which I am not sure is a bug in wxKill.
According to the documentation, using the wxKILL_CHILDREN flag will kill the process, as well as its children.
But what if these children have children too? in such case, my program leaves an orphan processes in the system.

I think a new flag should be added wxKILL_TREE - this will kill the process tree and not just the direct children.

The current implementation for windows, is implementing the following logic:

- take a snapshot of the system processes
- iterate over the processes, each process that it parent process id matches the process we want to kill, kill it as well.


To kill the process tree, another test should be added:
- in every iteration, check not only against the process id we want to kill, but also against the child processes we already killed.

- Eran

--
Eran Ifrah
eran....@gmail.com


--
Eran Ifrah
eran....@gmail.com

Eran Ifrah

unread,
Jun 22, 2007, 6:29:39 AM6/22/07
to wx-u...@lists.wxwidgets.org
Sorry for the late answer.
On Linux, it behaves as expected, since in order to make wxKill function to work properly, you need to pass wxEXEC_MAKE_GROUP_LEADER flag to wxExecute, when this is done, and wxKill flag is set to wxKILL_CHILDREN, it kills the whole group.

So in most cases it will behave  as expected (killing the whole tree), since in most cases tree == group.

I will make a fix for windows and submit it.
Eran

sds
On 6/21/07, Vadim Zeitlin <va...@wxwidgets.org> wrote:
On Wed, 20 Jun 2007 08:58:34 +0300 Eran Ifrah <eran....@gmail.com> wrote:

EI> I found out that a behavior which I am not sure is a bug in wxKill.
EI> According to the documentation, using the wxKILL_CHILDREN flag will kill the
EI> process, as well as its children.
EI> But what if these children have children too? in such case, my program
EI> leaves an orphan processes in the system.
EI>
EI> I think a new flag should be added wxKILL_TREE - this will kill the process
EI> tree and not just the direct children.

Could you please check if wxKILL_CHILDREN already behaves like this under
Unix? I think it should, in which case we don't need a new flag but just to
fix the existing code.

EI> The current implementation for windows, is doing the following logic:
EI> - take a snapshot of the system processes
EI> - iterate over the processes, each process that it parent process id matches
EI> the process we want to kill, kill it as well.
EI>
EI> To kill the process tree, another test should be added:
EI> - in every iteration, check not only against the process id we want to kill,
EI> but also against the child processes we already killed.

As usual, patches to implement this would be welcome (once the question
above is resolved).

Thanks,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
For additional commands, e-mail: wx-use...@lists.wxwidgets.org




--
Eran Ifrah
eran....@gmail.com
Reply all
Reply to author
Forward
0 new messages