Path: utzoo!attcan!utgpu!watmath!iuvax!uxc.cso.uiuc.edu!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.unix.wizards Subject: Re: csh pgrp problem Message-ID: <19000@mimsy.UUCP> Date: 11 Aug 89 10:21:02 GMT References: <712@skye.ed.ac.uk> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 26 In article <712@skye.ed.ac.uk> richard@aiai.ed.ac.uk (Richard Tobin) writes: >I believe I've found the problem, what I want to know is whether there's >a simple fix ... the shell forks twice (once for cat and once for more). >Each child sets its process group to the jobid, which is cat's process id. >The first child sets the terminal process group to the same thing. >However, there's nothing to guarantee that the first child sets the >terminal process group before the second child starts running ... > >Presumably using vfork() forces things to happen in the right order. This analysis is correct (congratulations: discovering this bug is rather tricky---the POSIX folks noticed it eventually, but it took quite a while). The accepted solution is to set the terminal's process group k+1 times when there are k children in a pipeline (or k times with the current system): once in each child and once in the parent. Setting the pgroup to whatever it is already is harmless, and this ensures that the pgroup is set by the time it needs to be. (Most of the mess would go away if process groups were allocated by the system, rather than by user code. But it is too late for POSIX.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris