Subject: Re: O_ASYNC on ttys
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-kern
Date: 07/07/2001 20:29:40
>>> I'm fairly certain that this change would break the POSIX
>>> conformance of our tcsetpgrp(3).
> Sorry, by "this change" I meant der Mouse's suggested change to

POSIX mandates that it must fail if the tty in question is not the
controlling tty of the calling process's session?  Then I submit -
because of exactly what I want to do here - that POSIX is broken and
should be ignored.

> After reading the thread in the archives, I'm not sure any of it is
> necessary.  O_ASYNC cares about the process group or PID indicated by
> an earlier call to fcntl(fd, F_SETOWN, pid) call, not the process
> group of a controlling tty.  So der Mouse should be able to get the
> SIGIO signals he wants without any kernel changes.

I suggest you try it - or at least read the code - before saying such
things.  If you read the implementation of F_SETOWN, you'll see that it
turns into a TIOCSPGRP call (except for sockets, for which it just
bashes so_pgid - there may be a third alternative now for new-pipes; I
haven't looked).

Or, if you *have* tried it, feel free to say so, but please also say
with what OS rev you tried it.  It doesn't work for me, and the code
makes it clear why.

> Below is an example using pipes.

Yes, with pipes it's easy.  Pipes are outside the whole controlling-tty
model.  Try it with ttys.  SIGIO is generated in ttwakeup() and is sent
to tp->t_pgrp.  The only place t_pgrp is set to a non-nil value are in
the code for TIOCSCTTY and TIOCSPGRP.

At least as far as I can tell, and the behavior I saw when I first
tried it bears me out.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B