[Gambas-user] Cascading child processes
Bruce
adamnt42 at gmail.com
Fri Dec 6 04:37:03 CET 2019
(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
More information about the User
mailing list