Subject: Re: Should FIOSETOWN convert pids to pgrps?
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-kern
Date: 03/20/2003 01:31:23
In article <20030319215626.Q580@snowdrop.l8s.co.uk>,
David Laight <david@l8s.co.uk> wrote:
>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.

Just an idea. Centralize all the code that does the FIOSETOWN/F_SETOWN.
Then rename TIOCSPGRP to OTIOCSPGRP and make the new TIOCSPGRP to only
set the process group for job control, and require FIOSETOWN/F_SETOWN
for async i/o. What do you think?

christos