[net.unix-wizards] SIGTTOU

m5@bobkat.UUCP (Mr Mike McNally) (10/15/86)

I have recently discovered a feature of the 4.2 tty driver which seems
contrary to the documentation.  The code to produce the effect is as
follows:

/*
    variable "new_pgrp_id" contains a valid process group identifier
    which is different from the distinguished process group for the
    terminal open on channel "tty_fd".
*/

    setpgrp(0, new_pgrp_id);
    ioctl(tty_fd, TIOCSPGRP, &new_pgrp_id);

Regardless of the setting of the LTOSTOP bit in the local modes, the
driver sends SIGTTOU upon the call to "ioctl".  I suppose I can agree
with the signal being sent if LTOSTOP were set (although I have not
seen any documentation indicating that the signal should be sent).
However, my notion of the purpose of LTOSTOP is that it prevents the
driver from EVER sending a SIGTTOU.

Am I just a babe-in-the-UNIX-woods for believing the tty(4)
documentation?  Is there a good reason for SIGTTOU to be sent
unconditionally upon ioctl calls from non-distinguished process group
processes which change the settings of the tty?

-- 
****                                                         ****
**** At Digital Lynx, we're almost in Garland, but not quite ****
****                                                         ****

Mike McNally                                    Digital Lynx Inc.
Software (not hardware) Person                  Dallas  TX  75243
uucp: ...convex!ctvax!bobkat!m5                 (214) 238-7474

thomas@utah-gr.UUCP (Spencer W. Thomas) (10/19/86)

In article <163@bobkat.UUCP> m5@bobkat.UUCP (Mr Mike McNally) writes:
>Regardless of the setting of the LTOSTOP bit in the local modes, the
>driver sends SIGTTOU upon the call to "ioctl".  I suppose I can agree
>with the signal being sent if LTOSTOP were set (although I have not
>seen any documentation indicating that the signal should be sent).
>However, my notion of the purpose of LTOSTOP is that it prevents the
>driver from EVER sending a SIGTTOU.

Well, the reasoning is that a process with a different pgroup is NOT the
current "foreground" process, and should therefore not be allowed to
change the tty modes.  SIGTTOU is indeed sent in this case.  LTOSTOP is
used to enable/disable sending of this signal to processes that attempt
to do output to the terminal when they are "background".  It thus
basically disallows background processes from printing if set.
Background processes are ALWAYS disallowed from changing tty modes.


To do what you are trying to do, you need to first open /dev/tty and do
a TIOCNOTTY ioctl on it.  Then you can do the TIOCSPGRP call.
Apparently this is "fixed" in 4.3.

-- 
=Spencer   ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA)