Re: Making terminal available for TIOCSCTTY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 09, 2003 at 12:29:45PM -0800, Ed Vance wrote:
> 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 ... 

Thanks, this should help. The trick is, that I have a program that
correctly claims controling tty, but I want to redirect it to
a different tty. And a terminal can not be a controling terminal of more
than one session. So I need something, that will keep the pty (terminal
emulator) open, but not a controling terminal of anything.

> -----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/
> 
-------------------------------------------------------------------------------
						 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/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux