<div dir="ltr">Hi,<div><br></div><div>While I'm not an expert in this part of wine, I want to point out that while it's definitely one way to do it, it's not the best way. You're relying on System() here which in turn relies on the output of the ps command. There's many potential issues here:</div><div><br></div><div>1. You have to make sure the output of the command you're executing will be the same across all systems. This could be an issue for cross-platform compatibility.</div><div>2. System() spawns extra processes which introduces overhead, which could be a problem on systems with limited resources.</div><div>3. 'ps' itself could have been removed, or modified maliciously, or only executable as root, probably anything could happen.</div><div><br></div><div>IMO, as much as possible, you should rely on using the existing API's provided within </div><div><br></div><div>François had posted an attachment in the comments containing a related implementation which you could refer. Hope it helps! You can find it here <a href="https://bugs.winehq.org/show_bug.cgi?id=39644#c1">https://bugs.winehq.org/show_bug.cgi?id=39644#c1</a><br></div><div><br></div><div>Feel free to ask any further questions you have. Make sure to CC wine-devel in your replies so other devs can see and help if need be.</div><div><br></div><div>Cheers,</div><div>Aaryaman</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 26, 2017 at 9:55 PM, Akarsha Sehwag <span dir="ltr"><<a href="mailto:akarsha15010@iiitd.ac.in" target="_blank">akarsha15010@iiitd.ac.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi<br>
I started with the bug( <a href="https://bugs.winehq.org/show_bug.cgi?id=39640" rel="noreferrer" target="_blank">https://bugs.winehq.org/show_<wbr>bug.cgi?id=39640</a> ).<br>
As of what I understood, I am writing it below. Kindly correct me<br>
wherever I go wrong.<br>
To implement ProcessPage_OnEndProcessTree() correctly we need to kill<br>
all its children and grandchildren also.<br>
So for that purpose, we need to iterate through all the active<br>
processes and check if their parent process is same as the process we<br>
wish to terminate. If yes, we kill them, if no, we continue our<br>
iteration.<br>
Now, for implementing this, can we use 'ps' or 'top' command.<br>
An example code:<br>
<br>
char string[30] = "ps -o pid --ppid ";<br>
char ppid[7];<br>
sprintf(ppid , "%d" , getpid() ) ;<br>
strcat ( string , ppid ) ;<br>
system ( string ) ;<br>
<br>
ps -o pid --ppid <parent_Id>  will give us the pid of all the<br>
child_processes whose parent has a PID. And now, get the parentProcess's<br>
PID by getpid(). Next, convert the integer into string and concatenate<br>
the result with string to get the final command which is then executed<br>
by system(string).<br>
<br>
Kindly tell me if I am anywhere near the right solution and also guide<br>
me how to proceed.<br>
<br>
Thanks :)<br>
Regards<br>
--<br>
Akarsha Sehwag<br>
<br>
<br>
</blockquote></div><br></div>