Discussion:
kill child processes on STOP to program GUARDIAN
(too old to reply)
Luis Silva
2021-02-04 02:00:10 UTC
Permalink
Hi,
I have an application written in C99 which calls PROCESS_LAUNCH_ to start other c99 programs.

When I runa a STOP command int TACL to my PROCESS_LAUNCH_ program I want to kill all children that were started by my program.

Is there a way to do that?

Rigth now if I kill parent program child programs are still up but not running.

Thank you in advance
Bill Honaker
2021-02-04 18:39:39 UTC
Permalink
Post by Luis Silva
Hi,
I have an application written in C99 which calls PROCESS_LAUNCH_ to start other c99 programs.
When I runa a STOP command int TACL to my PROCESS_LAUNCH_ program I want to kill all children that were started by my program.
Is there a way to do that?
Rigth now if I kill parent program child programs are still up but not running.
Thank you in advance
There is no standard builtin to do this. You can, of course, write a custom TACL routine to do that, but it's not very straightforward.
Bill
Keith Dick
2021-02-05 06:19:32 UTC
Permalink
Post by Luis Silva
Hi,
I have an application written in C99 which calls PROCESS_LAUNCH_ to start other c99 programs.
When I runa a STOP command int TACL to my PROCESS_LAUNCH_ program I want to kill all children that were started by my program.
Is there a way to do that?
Rigth now if I kill parent program child programs are still up but not running.
Thank you in advance
There is no standard builtin to do this. You can, of course, write a custom TACL routine to do that, but it's not very straightforward.
Bill
I think you can do what you want using the JOBID option of the RUN command and the STOP option of the STATUS command to stop the processes. I'm not absolutely sure this will work, and you are going to have to read the manuals to figure out the exact syntax.

If I remember correctly, the JOBID option can be used to make all processes started by the one you give the JOBID to have that same JOBID, so they can be associated with each other. When you do not use JOBID, the processes don't have an easy way to be associated with each other. The JOBID is just a number. You would specify it something like this:

RUN your-prog /JOBID 1/

Of course, you can include any other RUN options between the slashes, too.

The STATUS command has a way to select processes by JOBID. I believe you must specify both the top-level process's process name and the JOBID connected with a period.

So if you started your program using RUN your-prog/NAME $XYZ,JOBID 1/ then a command something like:

STATUS *, GMOMJOBID $XYZ.1

would show all the processes that have JOBID 1 and were started by $XYZ. If I'm remembering that correctly, you could stop them all with the command

STATUS *, GMOMJOBID $XYZ.1, STOP, FORCED

I don't remember whether those STATUS commands will include the top-level process $XYZ in their action. If not, you would have to stop it with a separate command. Or you could, write a fairly short TACL macro to combine the two commands so that you can enter just the command to run the macro (the top-level process name would be the argument to the macro).

It is possible I'm remembering some details of this incorrectly and you'll find it won't work as I think it does. If that is the case, describe the problem you run into and we might be able to figure out what I got wrong and fix it.

If something prevents this from working the way I think it does, another approach would be to make your top-level program open and read its $RECEIVE file, and if it receives a line containing whatever you want to use as a signal that it should stop, have it stop all the processes it started, then stop itself. Whether you would use an approach of reading from the $RECEIVE file every once in a while (with waited I/O and a short timeout) or use nowait I/O on $RECEIVE would depend on which is easier to fit into the logic of your program. Or if your program prompts for commands already, just define a new command that tells it to stop all the processes it started and then stop itself.
Continue reading on narkive:
Loading...