Subject: Re: F_SETOWN/TIOCGPGRP/FIOSETOWN handling
To: David Laight <david@l8s.co.uk>
From: Jaromir Dolecek <jdolecek@netbsd.org>
List: tech-kern
Date: 09/13/2003 22:37:06
David Laight wrote:
> I would keep TIOCSPGRP and F_SETOWN/FIOSETOWN completely separate.
> It is actually necessary to be able to do F_SETOWN (and O_ASYNC) on tty
> devices that are not controlling terminals.

It is completely separate - it's up to the end device/object
to decide what to do with the ioctl.
 
Note F_SETOWN used to just do TIOCSPGRP on the tty. There was never
any separate handling of F_SETOWN for ttys.

> You also need to keep a 'hold count' on the pgrp while the device is open
> (and maybe hasn't tried to signal a non-existant group) - otherwise it is
> possible to leave a device 'primed' to signal a group and not generate
> the signal until after the group has been deleted and re-created.

This is orthogonal problem to what I'm fixing now.
 
> You also need to do checks that the process doing the request is allowed
> to signal the specified process (group).

There is currently restriction that the process group must be
in caller's session group. There was no checking for target process
ID anywhere (it was always possible to set it to any process).
Again, I'm not changing this now - I'm just consolidating some
code.

> IIRC one of the compat ioctls lets the signal sent be changed from SIGIO.
> (So you also need to trawl the compat code...)

I looked at all places where TIOCSPGRP is handled now. I didn't
see anything special in compat code.
 
> I did wonder whether the existing kevent mechanism can easily be expanded
> to do the p{g}signal?

What do you mean?

Jaromir
-- 
Jaromir Dolecek <jdolecek@NetBSD.org>            http://www.NetBSD.cz/
-=- We should be mindful of the potential goal, but as the tantric    -=-
-=- Buddhist masters say, ``You may notice during meditation that you -=-
-=- sometimes levitate or glow.   Do not let this distract you.''     -=-