From owner-freebsd-questions@FreeBSD.ORG Thu Oct 12 21:36:23 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 42C3E16A605 for ; Thu, 12 Oct 2006 21:36:23 +0000 (UTC) (envelope-from freebsd@luna.afraid.org) Received: from smtp-2.orange.nl (smtp-2.orange.nl [193.252.22.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9DBBF43D7E for ; Thu, 12 Oct 2006 21:36:16 +0000 (GMT) (envelope-from freebsd@luna.afraid.org) Received: from gw.luna.afraid.org (s559292f8.adsl.wanadoo.nl [85.146.146.248]) by mwinf6102.orange.nl (SMTP Server) with ESMTP id 1289E1C00085; Thu, 12 Oct 2006 23:36:14 +0200 (CEST) X-ME-UUID: 20061012213615761.1289E1C00085@mwinf6102.orange.nl Received: from [127.0.0.1] (gw.luna.afraid.org [127.0.0.1]) by gw.luna.afraid.org (Postfix) with ESMTP id 6383FD8; Thu, 12 Oct 2006 23:36:14 +0200 (CEST) Message-ID: <452EB54E.1080605@luna.afraid.org> Date: Thu, 12 Oct 2006 23:36:14 +0200 From: Raaf User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.0.7) Gecko/20060927 Thunderbird/1.5.0.7 Mnenhy/0.7.4.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Murray Taylor Subject: Re: Question re ncurses and the various ttys X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Oct 2006 21:36:23 -0000 > Hi all > > I've been digging around in the various man pages and havent yet found > the > incantations I require. > > Goal: to create a curses driven status screen that can run without user > intervention. > > I want to know if it is possible to _programatically_ switch to an > unused > virtual tty, Yes it is certainly possible, i have done this recently myself and like you i couldn't find how to do it in any man page. Fortunately i could find the answer in the xorg-server source code. You just open one of the virtual terminals and issue the VT_ACTIVATE ioctl: fd = open("/dev/ttyv9",O_RDONLY); ioctl(fd,VT_ACTIVATE,10); > and then use this as the display page. > ( By unused I mean marked 'off' in /etc/ttys ) Well, the above code only switches the active vt... If you want your program output to go to a certain vt you probably have to open the specific vt and replace the stdin and stdout file descriptors of your program with the one of the one of the vt you just opened. But there are probably some caveats to this method, so best is to take a look at the getty source code and maybe add your program to /etc/ttys.