Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Mar 2012 02:10:21 +0100
From:      Nicholas Wilson <nicholas@nicholaswilson.me.uk>
To:        freebsd-x11@freebsd.org
Subject:   Working out which VT an X process is on
Message-ID:  <CAN%2BZGEnicY-UOB-5LO%2BxiUZKFpf7bFyUe3fv5reGh24ntNTofA@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAN%2BZGEnicY-UOB-5LO%2BxiUZKFpf7bFyUe3fv5reGh24ntNTofA>