[Gambas-user] User Digest, Vol 27, Issue 22
Steve G
simonlebon54 at yahoo.com
Fri Dec 6 19:42:56 CET 2019
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.
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.
Sent from TypeApp
On Dec 6, 2019, 02:15, at 02:15, user-request at lists.gambas-basic.org wrote:
>Send User mailing list submissions to
> user at lists.gambas-basic.org
>
>To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.gambas-basic.org/listinfo/user
>or, via email, send a message with subject or body 'help' to
> user-request at lists.gambas-basic.org
>
>You can reach the person managing the list at
> user-owner at lists.gambas-basic.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of User digest..."
>
>
>Today's Topics:
>
> 1. Cascading child processes (Bruce)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Fri, 6 Dec 2019 14:07:03 +1030
>From: Bruce <adamnt42 at gmail.com>
>To: Gambas Mailing List <user at lists.gambas-basic.org>
>Subject: [Gambas-user] Cascading child processes
>Message-ID: <a81bbd3a-f729-f358-bbf9-084897309e82 at gmail.com>
>Content-Type: text/plain; charset=utf-8; format=flowed
>
>(I am trying to speed up searching an increasingly large database and a
>
>bunch of websites)
>
>The search program now either invokes child processes via "newproc =
>Exec ..." or spawns via Shell. This is all fine and some of these
>processes invoke their own set of children. Since most of them spend
>most of their time waiting for an internet response or a complex SQL
>query, they are mainly sleeping.
>
>Now occasionally, the searches take too long. So I want to terminate
>them (and all their children) from the top level program, but not the
>top level program ("SMain") itself.
>
>I have tried using Gambas process.Kill(), process.Signal(),
>gb.signal.Send(blah, blah) and shelling out to the "Kill" command
>itself.
>
>None of these have been successful. All let me terminate the process
>invoked by SMain but all their children are left running.
>
>Looking at man 2 kill it says "If pid is less than -1, then sig is sent
>
>to every process in the process group whose ID is -pid." This does let
>me send a SIGTERM to all the processes cascading from SMain, but
>unfortunately sends the signal to SMain itself.
>
>I can't see a way to ignore or block a SIGTERM in SMain itself (and I
>am
>not sure that I really want to).
>
>So, is there something that I am not seeing/understanding here or do I
>need to cascade the signalling down through all these programs ( and if
>
>so how do I trap a signal?)?
>
>tia
>bruce
>
>
>
>
>------------------------------
>
>Subject: Digest Footer
>
>----[ Gambas mailing-list is hosted by https://www.hostsharing.net
>]----
>
>
>------------------------------
>
>End of User Digest, Vol 27, Issue 22
>************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20191206/4b1e9e57/attachment-0001.html>
More information about the User
mailing list