From owner-freebsd-hackers Tue Mar 4 14:59:30 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id OAA21924 for hackers-outgoing; Tue, 4 Mar 1997 14:59:30 -0800 (PST) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id OAA21919 for ; Tue, 4 Mar 1997 14:59:27 -0800 (PST) Received: from enst.enst.fr (enst.enst.fr [137.194.2.16]) by who.cdrom.com (8.7.5/8.6.11) with ESMTP id OAA28556 for ; Tue, 4 Mar 1997 14:59:25 -0800 (PST) Received: from email.enst.fr (email.enst.fr [137.194.168.17]) by enst.enst.fr (8.8.4/8.8.4) with ESMTP id XAA19627; Tue, 4 Mar 1997 23:57:46 +0100 (MET) Received: from nikopol.enst.fr (nikopol.enst.fr [137.194.168.105]) by email.enst.fr (8.8.4/8.8.4) with ESMTP id XAA15857; Tue, 4 Mar 1997 23:57:39 +0100 (MET) Received: (from fenyo@localhost) by nikopol.enst.fr (8.8.4/8.8.4) id XAA13518; Tue, 4 Mar 1997 23:57:36 +0100 (MET) To: Ray Cummins Cc: Andrzej Bialecki , freebsd-hackers@FreeBSD.ORG X-WWW: http://home.eowyn.fr.eu.org/~fenyo/documents/axel.html X-PGP-Key: finger alex@eowyn.fr.eu.org X-NIC-Handle: AF713 X-Whois: whois -h whois.internic.net fenyo X-Pager: 06-04-30-75-94 (for emergency only) Organization: Ecole Nationale Superieure des Telecommunications de Paris Subject: Re: "stealing" pty/vty References: From: fenyo@email.enst.fr (Alex Fenyo (eowyn)) Date: 04 Mar 1997 23:57:33 +0100 In-Reply-To: Ray Cummins's message of Mon, 24 Feb 1997 08:25:08 -0500 (EST) Message-ID: Lines: 30 X-Mailer: Red Gnus v0.50/XEmacs 19.14 Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Ray Cummins 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