From owner-freebsd-x11@FreeBSD.ORG Sat Mar 31 01:10:25 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 B4B07106564A for ; Sat, 31 Mar 2012 01:10:25 +0000 (UTC) (envelope-from nicholas@nickcwilson.co.uk) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 3C9D88FC0C for ; Sat, 31 Mar 2012 01:10:24 +0000 (UTC) Received: by wgbds12 with SMTP id ds12so1020750wgb.31 for ; Fri, 30 Mar 2012 18:10:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=bysGS/g2xnJWt9JvFoUcdaj/CB8pWhYktau6/YUViic=; b=PBtS7iLwuOeUDBUlzOTQL42lHeMvNT3Bprx7Q+d1YTVDR8sEflAUGev10xs23nbBst Qvkp9yi9vE6Yb0lPwrMqCmCj/uBPEIfDIqB26jBd2pkxqUFIeBC75o+6MP8K18PCSXG/ Aa4FpO0A0SzdhmkbDdwQ84oZnBGDO7hX0XyVtUiC+UxDhfRY/6KIaw05z2SF1DNCoEv6 Sox+YK7O2DA6yVqRTQiEy3Y4mC6Sm1WiCRxdAIsEnqWA3+3L+swAOdlE7tgo85aZHvyK 1uEeahjs98Sp9X3dvpq1URWA4KBOQBXqrQBL6TFsH77rYanJajajiMUWBOiobesHB3oU CI/Q== Received: by 10.180.84.164 with SMTP id a4mr1736083wiz.2.1333156223736; Fri, 30 Mar 2012 18:10:23 -0700 (PDT) Received: from mail-bk0-f54.google.com (mail-bk0-f54.google.com [209.85.214.54]) by mx.google.com with ESMTPS id b3sm11082752wib.4.2012.03.30.18.10.22 (version=SSLv3 cipher=OTHER); Fri, 30 Mar 2012 18:10:22 -0700 (PDT) Received: by bkcjc3 with SMTP id jc3so1303548bkc.13 for ; Fri, 30 Mar 2012 18:10:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.204.155.143 with SMTP id s15mr193260bkw.44.1333156221995; Fri, 30 Mar 2012 18:10:21 -0700 (PDT) Received: by 10.204.67.137 with HTTP; Fri, 30 Mar 2012 18:10:21 -0700 (PDT) X-Originating-IP: [92.40.254.140] Received: by 10.204.67.137 with HTTP; Fri, 30 Mar 2012 18:10:21 -0700 (PDT) Date: Sat, 31 Mar 2012 02:10:21 +0100 Message-ID: From: Nicholas Wilson To: freebsd-x11@freebsd.org X-Gm-Message-State: ALoCoQll8wJEgyALTUZJ98otxputHaNa17ZSaWUIwaCyMt00UzHZUIBriQnNCtQ9D5+pd3A9egTj Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: 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 01:10:25 -0000 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.) 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