John wrote:
>I skimmed through the O'Reilly books on POSIX, and was unable to find any
>references to setting the controlling terminal. My best guess is that the
>following comment may be a reference to tcsetpgrp, which can be used to
>specify the process group in the current session which should be in the
>"foreground".
> /* FIXME: According to [EMAIL PROTECTED], there's a cleaner POSIX way
> * to make a tty the process's controlling tty. */
>A note on the streams modules: perhaps ttcompat should be pushed onto the
>slave pty as well. Quoting from APUE:
>"ttcompat provides compatibility for older V7, 4BSD, and Xenix ioctl
>calls. It's an optional module but since it's automatically pushed for
>console logins and network logins, we push it onto the slave's stream."
i recommend looking at W. Richard Stevens' "Advanced Programming in the
UNIX Environment" for this sort of thing. it explains all the rules
governing controlling terminals in different systems.
the easy way to get a controlling terminal is to close any ttys
(particularly the current controlling terminal), become a session
leader (setsid()) and then open a tty (without the O_NOCTTY flag).
it will be the new controlling tty.
it might be a bit trickier if another process is the session leader
and you want it to stay that way.
and my apologies if i've misunderstood the point of the mail to which
i'm responding :)
raf