Xref: utzoo comp.unix.programmer:1849 comp.unix.shell:2208 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!haven.umd.edu!decuac!nntpd.lkg.dec.com!netrix.nac.dec.com!lan_csse From: lan_csse@netrix.nac.dec.com (CSSE LAN Test Account) Newsgroups: comp.unix.programmer,comp.unix.shell Subject: Re: What does csh require of its tty? Message-ID: <22738@shlump.lkg.dec.com> Date: 17 May 91 15:22:45 GMT References: <22736@shlump.lkg.dec.com> Sender: news@shlump.lkg.dec.com Followup-To: comp.unix.programmer Organization: Digital Equipment Lines: 49 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 or +----------------------------------------------------------------+