Re: Making terminal available for TIOCSCTTY

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

 



On Thu, Jan 09, 2003 at 03:50:52PM -0800, Ed Vance wrote:
> On Thu, Jan 09, 2003 at 3:11 PM, Jan Hudec wrote:
> > On Thu, Jan 09, 2003 at 03:05:56PM -0800, Ed Vance wrote:
> > > On Thu, Jan 09, 2003 at 2:21 PM, Jan Hudec wrote:
> > > > I think, that it's a bit different. It should look like 
> > > > following:
> > > > process A has pty/1 as ctty.
> > > > process A makes pty/1 available (presumably via TIOCNOTTY)
> > > > process B has no ctty (there is something about setsid I 
> > > > don't fully understand)
> > > > process A tells process B that it can use pty/1
> > > > process B opens pty/1 and makes it it's controlling terminal 
> > > > (TIOCSCTTY)
> > > > 
> > > > The reason behind this: I have a process that logs a LOT to
> > > > stdout/stderr, does "setterm" ioctls on it and needs WINCH 
> > > > signal (thus a controlling tty). I want to run it from gdb 
> > > > and have gdb and this programs output separated. Thus I use 
> > > > gdb's tty command. But I need to make a tty available (under 
> > > > X, that is in some terminal emulator).
> > > > 
> > > 
> > > If B calls setsid() successfully, then B opening pty/1 should
> > > make pty/1 ctty of B. Should not need to use TIOCSCTTY ioctl 
> > > unless pty/1 still has a session attached, which it will if 
> > > process A was not the session leader. Then you would not need 
> > > the TIOCNOTTY and would need to use TIOCSCTTY with arg=1 to 
> > > wrestle pty/1 away from its current group. Which call is 
> > > returning an error?
> > 
> > The TIOCSCTTY. The problem is, that TIOCSCTTY with arg=1 only 
> > works for superuser (at least seems so from kernel source). Thus 
> > I need to detach the terminal properly...
> 
> I understand. TIOCNOTTY must be called from the session leader to 
> free up the tty. Otherwise, the calling process is removed from the 
> tty, but the tty remains attached to the other processes in the 
> session, which prevents TIOCSCTTY from using it. I don't see a 
> non-superuser way to do it yet, unless the actual session leader 
> can be made to do the TIOCNOTTY.

Yes. Now, since it's a terminal emulator, the shell should be the
session leader (it should be true even on console). Now I see two ways
to make it give up controling tty. Either exec the script to give it up,
or have the terminal emulator run it from the very start. Now I only
have to find out, why is the script failing, when it's exec'd.

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