Subject: Re: job-control shell trouble
To: None <tech-userlevel@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-userlevel
Date: 12/28/2004 01:58:28
[Andrew Brown <atatat@atatdot.net>, not Christos this time]

> if A->B->C->C' and then C gives up the ghost and B->D, why not simply
> put D into pgrp D?  if C' isn't dead, you can't use C as a pgrp.

Why not?  C' is still in it.

It certainly seems to work when I try it.  I tried it on NetBSD/i386
2.0 and on NetBSD/sparc 1.4T, and it worked fine in both cases.  The
test program I used is up on ftp.rodents.montreal.qc.ca in
/mouse/misc/pgrp-test.c if you want to have a look, or try it yourself,
or whatever.  The output should look something like

B = 10983 [10983]
C = 10984 [10984]
C' = 10985 [10984]
C' = 10985 [10984]
D = 10986 [10984]

(which is what I got on NetBSD/sparc 1.4T) or

B = 2089 [2089]
C = 14291 [14291]
C' = 20932 [14291]
C' = 20932 [14291]
D = 3205 [14291]

(which is what I got on NetBSD/i386 2.0).  The important point is that
all five lines of output are present, and the last four have the same
number in brackets - that number is the process group.

>> They need to be in the proper process group so that the correct sets
>> of processes get tty-generated signals, if nothing else.
> then it sounds to me like you'd want C' to be in a different process
> group from the current process group so that it didn't get signals
> aimed at a different set of processes (aka pgrp D).  no?

No.  You see, D and C and C' are all part of the same conceptual `job',
so a tty-generated signal aimed at that job should hit whichever of
them are currently alive.  If D were in a different job, yes, it would
need to get its own pgrp.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B