<html><head></head><body style="zoom: 0%;"><div dir="auto">It seems to me that since you are using a recursive algorithm to spawn these various processes. You will also need to build into that recursive algorithm a recursive kill. Something that you could send to one of the processes, that tells it to kill itself and all of its children. And then of course since it's recursive we send that kill signal down the recursive line. <br></div>
<div dir="auto">Basically each process when it receives a kill signal which you can Define any way you would like, it first sends that signal to any of its children processes before terminating itself. This should take care of any process you try to kill and all of its children regardless of where in the recursion tree that is.<br><br></div>
<div dir="auto"><!-- tmjah_g_1299s -->Sent from <!-- tmjah_g_1299e --><a href="http://www.typeapp.com/r?b=15723"><!-- tmjah_g_1299s -->TypeApp<!-- tmjah_g_1299e --></a><!-- tmjah_g_1299s --> <!-- tmjah_g_1299e --></div>
<div class="gmail_quote" >On Dec 6, 2019, at 02:15, <a href="mailto:user-request@lists.gambas-basic.org" target="_blank">user-request@lists.gambas-basic.org</a> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="blue">Send User mailing list submissions to<br> user@lists.gambas-basic.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> <a href="http://lists.gambas-basic.org/listinfo/user">http://lists.gambas-basic.org/listinfo/user</a><br>or, via email, send a message with subject or body 'help' to<br> user-request@lists.gambas-basic.org<br><br>You can reach the person managing the list at<br> user-owner@lists.gambas-basic.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of User digest..."<br><br><br>Today's Topics:<br><br> 1. Cascading child processes (Bruce)<br><br><br><hr><br><br>Message: 1<br>Date: Fri, 6 Dec 2019 14:07:03 +1030<br>From: Bruce <adamnt42@gmail.com><br>To: Gambas Mailing List <user@lists.gambas-basic.org><br>Subject: [Gambas-user] Cascading child processes<br>Message-ID: <a81bbd3a-f729-f358-bbf9-084897309e82@gmail.com><br>Content-Type: text/plain; charset=utf-8; format=flowed<br><br>(I am trying to speed up searching an increasingly large database and a <br>bunch of websites)<br><br>The search program now either invokes child processes via "newproc = <br>Exec ..." or spawns via Shell. This is all fine and some of these <br>processes invoke their own set of children. Since most of them spend <br>most of their time waiting for an internet response or a complex SQL <br>query, they are mainly sleeping.<br><br>Now occasionally, the searches take too long. So I want to terminate <br>them (and all their children) from the top level program, but not the <br>top level program ("SMain") itself.<br><br>I have tried using Gambas process.Kill(), process.Signal(), <br>gb.signal.Send(blah, blah) and shelling out to the "Kill" command itself.<br><br>None of these have been successful. All let me terminate the process <br>invoked by SMain but all their children are left running.<br><br>Looking at man 2 kill it says "If pid is less than -1, then sig is sent <br>to every process in the process group whose ID is -pid." This does let <br>me send a SIGTERM to all the processes cascading from SMain, but <br>unfortunately sends the signal to SMain itself.<br><br>I can't see a way to ignore or block a SIGTERM in SMain itself (and I am <br>not sure that I really want to).<br><br>So, is there something that I am not seeing/understanding here or do I <br>need to cascade the signalling down through all these programs ( and if <br>so how do I trap a signal?)?<br><br>tia<br>bruce<br><br><br><br><br><hr><br><br>Subject: Digest Footer<br><br>----[ Gambas mailing-list is hosted by <a href="https://www.hostsharing.net">https://www.hostsharing.net</a> ]----<br><br><br><hr><br><br>End of User Digest, Vol 27, Issue 22<br>************************************<br></pre></blockquote></div></body></html>