Skip site navigation (1)Skip section navigation (2)
Date:      04 Mar 1997 23:57:33 +0100
From:      fenyo@email.enst.fr (Alex Fenyo (eowyn))
To:        Ray Cummins <rcummins@burlco.lib.nj.us>
Cc:        Andrzej Bialecki <abial@korin.warman.org.pl>, freebsd-hackers@FreeBSD.ORG
Subject:   Re: "stealing" pty/vty
Message-ID:  <d06wwrnz2n6.fsf@nikopol.enst.fr>
In-Reply-To: Ray Cummins's message of Mon, 24 Feb 1997 08:25:08 -0500 (EST)
References:  <Pine.NEB.3.95.970224082440.12774A-100000@burlco-00.burlco.lib.nj.us>

next in thread | previous in thread | raw e-mail | index | archive | help
Ray Cummins <rcummins@burlco.lib.nj.us> writes:
> On Mon, 24 Feb 1997, Andrzej Bialecki wrote:
>
> > Sometimes I run into following problem: I start a process on a console (or
> > vty) and then go home only to remember that I have to "press any key" for
> > the damn process to continue... But how to do it, even if I log in and su
> > to root?
> > 
> > Is there a way to tap into the vty used by process and interact with it?
> > 
> 
> man "watch"

Another way to do it is to use the TIOCSTI ioctl.  STI is for Simulate
Terminal Input.  Write a program which  open the controling tty of the
process that  is waiting for a key,  and then  make  a TIOCSTI  with a
pointer to  "\n" as an argument on  the filedescriptor of the  tty. It
will simulate a "\n" coming  from the pty (you  cannot simply write  a
"\n" on the  pty  because it  cannot be   opened twice and   getty -or
xterm...- has  previously  opened it  before  launching the shell that
activated your   program  waiting for  a   key).   Then, it   will  be
interpreted  by the  program like a   "\n" typed  on your  console (or
xterm).  This    method works   not   only on   FreeBSD  but  on  most
BSD-derivated systems too because it doesn't make use of the tty snoop
interfaces.  (I've tested it with success on SunOS 4.x too).

Sincerly,
Alexandre Fenyo





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d06wwrnz2n6.fsf>