chas@vision.UUCP (Charles Hirst) (03/21/90)
Can anybody on the net help I am currently porting a windowing device driver to a HP 9000 series 825 machine running Version 7 of HP-UX. The device driver in question is PC-Connect if it means anything to anybody. As of the moment it all works fine except for one problem. When a csh is run in one of the virtual windows it appears to work. If however you run say ls in the shell window, the csh places it in the background. It will not allow you to pull it back to the forground either. I traced the problem to the failure of the TIOCSPGRP ioctl issued by the csh. As this fails, the newly forked process, e.g. ls is not a process group leader as the shell is expecting it to be. The csh therefore shoves it into the background. I have got round this problem by implementing the TIOCSPGRP ioctl myself. Normally we handle any ioctls recieved by our pseudo devices that are specific to our driver and then pass the rest down to l_control and l_ioctl. However if I pass the TIOCSPGRP ioctl down it fails with error 25, ENOTTY. As a fix I trap it myself and simply fill the tty t_pgrp field in with the supplied argument ( the requested pid to set process group to ). Can anybody tell me what fields need filling in, in a tty structure during the open routine. Looking at the tty struct does not help as HP have played with it a lot to get POSIX compatibility. I currently treat it like a BSD structure. The driver used to work with version 3 of HP-UX, if that helps. Many thanks. -- -------------------------------------------------------------------------------- || / / || / / Charles Hirst Life is but a bowl || / / Software Engineer of worm gears ! || / / ||//| / chas@vision.UUCP VisionWare Ltd, | / | / ...!uunet!mcsun!ukc!vision!chas 57, Cardigan Lane, |/ |/ +44-532-788858 Leeds, LS4 2LE, United Kingdom -------------------------------------------------------------------------------- VISIONWARE DOS/UNIX Integration --------------------------------------------------------------------------------
rml@hpfcdc.HP.COM (Bob Lenk) (03/28/90)
In message <1054@vision.UUCP> chas@vision.UUCP (Charles Hirst) writes: > I traced the problem to the failure of the TIOCSPGRP ioctl issued by the > csh. > ... > However if I pass the TIOCSPGRP ioctl down it fails with error 25, > ENOTTY. As a fix I trap it myself and simply fill the tty t_pgrp field > in with the supplied argument ( the requested pid to set process group > to ). > > Can anybody tell me what fields need filling in, in a tty structure > during the open routine. Looking at the tty struct does not help as HP > have played with it a lot to get POSIX compatibility. I currently treat > it like a BSD structure. > > The driver used to work with version 3 of HP-UX, if that helps. Most likely the problem is due to POSIX security requirements on the ioctl call (actually the POSIX tcsetpgrp() call, which is the same thing). POSIX requires that the tty be the controlling tty of the calling process and that the tty be associated with the session of the calling process. Your solution is essentially defeating these checks; note that it could cause security problems in some environments. Earlier versions of HP-UX used different checks based on uids instead. The check probably is based on fields in the proc or user structure, as well as the tty structure that point to or otherwise identify each other. If I understand your "driver" to be a user process at the master end of a pty, it shouldn't be handling these directly. The best way to handle this is probably to make sure that the session in the window is initialized properly to create the affiliations. This requires that the session leader (probably whatever exec's csh) be the first to open the slave, and that it call setsid(2) or setpgrp(2) before opening the slave (details on termio(7)). Bob Lenk rml@hpfcla.hp.com hplabs!hpfcla!rml