From owner-freebsd-x11@FreeBSD.ORG Sat Mar 31 09:40:06 2012 Return-Path: Delivered-To: freebsd-x11@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 58849106564A for ; Sat, 31 Mar 2012 09:40:06 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 756878FC15 for ; Sat, 31 Mar 2012 09:40:04 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id MAA01884; Sat, 31 Mar 2012 12:39:56 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1SDumq-0009de-1C; Sat, 31 Mar 2012 12:39:56 +0300 Message-ID: <4F76D0E9.7060006@FreeBSD.org> Date: Sat, 31 Mar 2012 12:39:53 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:10.0.2) Gecko/20120218 Thunderbird/10.0.2 MIME-Version: 1.0 To: Nicholas Wilson References: In-Reply-To: X-Enigmail-Version: 1.4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: freebsd-x11@FreeBSD.org Subject: Re: Working out which VT an X process is on X-BeenThere: freebsd-x11@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: X11 on FreeBSD -- maintaining and support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Mar 2012 09:40:06 -0000 on 31/03/2012 04:10 Nicholas Wilson said the following: > Hello, > > I'm working at the moment on porting a VNC product to FreeBSD, and have run > into a little problem which I hope I can get some help on. In brief: I > can't find a way of determining which virtual terminal is in use by a given > X process. > > On linux, when X opens a handle to the tty it's going to run on, it > acquires it as a controlling terminal. So, if there are two X processes, > and we see that tty7 and tty8 are in use, it's obvious from ps which > process is which, and hence by inspecting the processes' environments we > can quickly establish which display number goes with which VT. (On the > other UNIX platforms we support, like AIX, we don't need to worry about VTs > at all.) Not sure if there is a better way, but fstat -p ${X_SERVER_PID} | fgrep tty should give what you want. You need to have enough privileges to get information about the X process. > On BSD, I don't think it's possible to get this behaviour, identifying the > X processes on a multi-user system by their controlling terminal. I develop > a fork of Xvnc, so I've already read the relevant Xorg code, but I'm fairly > new to BSD. If there is a way to configure or launch X apropriately I'd be > grateful to hear it. I can easily hack X with an ioctl to do this, but I > want to be able to follow the stock Xorg X server. > > Some background: one of the programs we distribute is a "service-mode > server" which follows the console and attaches itself to the X server on > the currently-active VT. I would like our FreeBSD server to be able to > follow the console, like our linux server does, and switch X server when > the user uses Alt-Fn or 'switch user' in GNOME. > > I'm not dead set on controlling terminals if there's another way of getting > the information. My current best workaround is to grep the X logs, where > the vt is reliably printed, but this feels dirty. > > My experience of porting to BSD has been excellent otherwise; very little > effort at all, and in a very neat environment that feels comfortable and > modern compared to Solaris and HP-UX. Thank you for any help or pointers > you can give, and for distributing a great system. > > Best, > Nicholas > > --- > Nicholas Wilson > Cambridge, UK > _______________________________________________ > freebsd-x11@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-x11 > To unsubscribe, send any mail to "freebsd-x11-unsubscribe@freebsd.org" > -- Andriy Gapon