Subject: Should FIOSETOWN convert pids to pgrps?
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 03/19/2003 21:56:26
At the moment both ioctl(fd, FIOSETOWN, &pid) and fcntl(fd, F_SETOWN, pid)
convert process ids to process group ids before passing then to the
device driver (as ioctl(fd, TIOCSPGRP, &-pid)).

This is contrary to the fcntl man page:

F_SETOWN Set the process or process group to receive SIGIO and SIGURG
	signals; process groups are specified by supplying arg as neg-
	ative, otherwise arg is interpreted as a process ID.  The ar-
	gument arg is interpreted as an int.

and ioctl page:

FIOSETOWN, FIOGETOWN int
	Set/get the process or the process group (if negative) that
	should receive SIGIO signals when data is available.

The values are also dumped straight into the so_pgid field for
sockets (rather than the socket code processing the TIOCSPGRP ioctl).

It seems to me that this code should not be present, and that the socket
code should do its own work.
(IIRC it has been changed in either OpenBSD or FreeBSD).

The other related code is in kern/tty.c
This is slightly complicated by the fact that TIOCSPGRP is used for
both async io and job control (via tcsetpgrp()).
It also needs to be possible to do async io on serial devices that are
no ones controlling terminal.

For ttys we need a field to hold the pid/pgid for async io on
non-controlling terminals (ie when tp->t_session == NULL).
Setting this non-zero would bar the tty from becoming a ctty (or
do we just ignore the value?)

I'm not sure it is necessary to re-instate the pid -> pgrp conversion
for ttys  (all the other driver code expects to send SIGIO to both
processes and process groups).

Thoughts before I get my coding stick out?

	David

-- 
David Laight: david@l8s.co.uk