in reply to Re^2: Handling badly behaved system calls in threads
in thread Handling badly behaved system calls in threads

You're implying that if you use fork (i.e. create child processes), the workers won't be in the same process group. That's not true. A process group is a group of processes, not a group of threads. (Mind you, all your threads will be in the same process group by virtue of being in the same process.)

if (!fork()) { sleep; exit(0); } if (!fork()) { sleep; exit(0); } kill TERM => $$; # Only kills self
if (!fork()) { sleep; exit(0); } if (!fork()) { sleep; exit(0); } kill -TERM => $$; # Kills all three processes

Replies are listed 'Best First'.
Re^4: Handling badly behaved system calls in threads
by kennethk (Abbot) on Sep 07, 2010 at 15:56 UTC
    Sorry, upon rereading I see I expressed myself poorly. I meant to say that I need to be able to kill one and only one lineage of processes. At any given time, I may be executing 20 different threaded tests within the main executable. Each test will create a child (the shell) and a grandchild (the badly-behaved executable). I was concerned that if I killed the process group (changing the main's pgid to avoid the axe), all currently running executables, not just the failing one, would be killed. Hence, killing the process group would mean one failing test may take 19 good ones out with it.

    Please correct me if I am ill-informed.