Hi Jan, IIRC, a process must first have no controlling tty to get a new one assigned on the next open of a tty. Controlling tty assignments are sticky and are unaffected by closing. Once assigned, the assignment persists even if the process closes or redirects all streams open to that tty. For example, a process still receives signals generated the keyboard of its controlling tty, even if all streams have been redirected. By default, a child process inherits the parent's controlling tty assignment. So, the child process must use the TIOCNOTTY ioctl on its controlling tty to remove the controlling tty assignment. It does not matter that a stream is already open to the previous controlling tty. Then, the next open of a tty will assign that tty as the new controlling tty, unless it is opened with the O_NOCTTY flag or the tty is already the controlling tty of another process, which it will be if there was a getty on it. I hope I got that right ... Ed -----Original Message----- From: Jan Hudec [mailto:bulb@ucw.cz] Sent: Thursday, January 09, 2003 11:33 AM To: kernelnewbies@nl.linux.org Subject: Re: Making terminal available for TIOCSCTTY On Wed, Jan 08, 2003 at 01:50:45PM -0800, Seth Arnold wrote: > On Tue, Jan 07, 2003 at 01:26:24PM +0100, Jan Hudec wrote: > > Is it somehow possible to obtain a pty (not interested in usused virtual > > console - only in different kinds of teminal emulators) so that > > a process that has it's stdin, stdout and stderr redirected there can > > claim it it's controling tty? > > Between the ioctl TIOCNOTTY and opening new terminal devices without > using O_NOCTTY should re-associate your process with a new terminal. > (Check open(2) for more hints.) I know how to make a pty my controling terminal. I however don't know how to make a pty suitable for using as controling tty for a process, whose parent has completely different controling tty. ---------------------------------------------------------------------------- --- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/