Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Mar 2012 19:17:38 +0100
From:      Nicholas Wilson <nicholas@nicholaswilson.me.uk>
To:        Andriy Gapon <avg@freebsd.org>, "freebsd-x11@freebsd.org" <freebsd-x11@freebsd.org>
Subject:   Re: Working out which VT an X process is on
Message-ID:  <CAN%2BZGEmuUSt-mn_FfHjCUAqaUiorrzhfOfNzVW9f9LsPTBwCLQ@mail.gmail.com>
In-Reply-To: <4F76D0E9.7060006@FreeBSD.org>
References:  <CAN%2BZGEnicY-UOB-5LO%2BxiUZKFpf7bFyUe3fv5reGh24ntNTofA@mail.gmail.com> <4F76D0E9.7060006@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mar 31, 2012 10:39 AM, "Andriy Gapon" <avg@freebsd.org> wrote:
>
> 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.
>
> --
> Andriy Gapon

Oh! That makes it look so obvious. I'd been fixated on the fact that we
can't rely on proc on BSD, so fuser wouldn't work like does on linux. Of
couse there must be a sysctl-based equivalent for getting the X process's
fds! I'm sure I can work it out now.

Many thanks,
Nicholas



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAN%2BZGEmuUSt-mn_FfHjCUAqaUiorrzhfOfNzVW9f9LsPTBwCLQ>