[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Making terminal available for TIOCSCTTY
On Thu, Jan 09, 2003 at 2:21 PM, Jan Hudec wrote:
> On Thu, Jan 09, 2003 at 02:13:42PM -0800, Ed Vance wrote:
> > On Thu, Jan 09, 2003 at 12:42 PM, Jan Hudec wrote:
> > >
> > > 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
> > > > [ ... ]
> > > >
> > > > 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.
> >
> > Do you mean something like the following sequence?
> >
> > process A has serial port as CTTY.
> > process A opens a master pseudo terminal.
> > process A forks child process B.
> > process B ioctl TIOCNOTTY serial port to remove B's CTTY
> > assignment.
> > process B closes serial port streams.
> > process B opens corresponding slave pseudo terminal,
> > becomes B's CTTY.
>
> 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 controling 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 controling 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?
----------------------------------------------------------------
Ed Vance edv (at) macrolink (dot) com
Macrolink, Inc. 1500 N. Kellogg Dr Anaheim, CA 92807
----------------------------------------------------------------
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/