What does csh require of its tty?

CSSE LAN Test Account lan_csse at netrix.nac.dec.com
Sat May 18 01:22:45 AEST 1991


Here I go following up my own article...

Well, I got a bit more evidence as to why csh is hanging on some
ports and not on others.  There seems to be something bizarre with
the process groups.  Part of the evidence is that ps says:
	jc       10224  2.7  0.3   29   27 ?  S     0:02 - (sh)
I.e., it doesn't know what tty the sh is running on.  If I go to
the other machine and type "echo hi >/dev/tty" in the window that
is connected over here, it says 
	/dev/tty: cannot create
When I do the same in other windows, I get "hi" like you'd expect.

So the daemon controlling the port hasn't set up the process group
correctly.  The Ultrix tty(4) manual page says:
	A terminal's associated process group may be set using the
	TIOCSPGRP ioctl(2):
		ioctl(fildes, TIOCSPGRP, &pgrp)
The code that sets the process group looks like:
	if ((i = setpgrp(pid,pid)) == 0) {
		P2("%s  Set process group to %d",dbgtime(),pid);
		if ((i = ioctl(dev,TIOCSPGRP,&pid)) == 0) {
			P2("%s  Set process group to %d for %s",dbgtime(),pid,device);
		} else
			P1("%s  ### Can't set pgrp to %d for %s [Err %d=%s]",
				dbgtime(),pid,device,Erreason);
	} else
		P1("%s  ### Can't set process group to %d [Err %d=%s]",
			dbgtime(),pid,Erreason);
where the P*() routines are macros that are conditional prints to an
audit trail.  This audit trail shows both of the P2() messages; i.e.,
the success messages.  The value of pid is the pid of the process in
which the shell starts, dev is the file handle for the port, device
is its name, and the rest is debug stuff that I won't explain.

It's especially curious that the above code seems to work fine on some
of the Ultrices around here and not on others.  I conclude that there's
something else required to make it work, but I haven't a clue as to what
it might be.

And of course I'm still looking for a more general solution that will
work on any Unix.  On Sys/V, the equivalent of the above code is just:
	setpgrp();
and it seems to work without any hassles, for sh, csh, and ksh.

Any ideas as to what I could be doing wrong?

+----------------------------------------------------------------+
Reply-to: John Chambers <jc at sppip7.lkg.dec.com> or <ub40.enet::jc> 
+----------------------------------------------------------------+



More information about the Comp.unix.programmer mailing list