[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to determine the VT of a running X session?



> > fgconsole (1)        - print the number of the active VT.
> > ...
> >
> > It seems to need super user privileges though.  I can see why super
> > user privileges should be necessary for chvt but not fgconsole.  Does
> > anyone know why or should it be reported as a "bug".
>
> Hi,
>
> it doesn't need root privileges here... this is basically all it's doing
> (I hadn't found fgconsole, so I wrapped up something similar):
>
...
>
> Apparently VT_GETSTATE doesn't work when you're under X (returns EINVAL)...

I hadn't tried it outside of X and there it does work as a non-root
user.  but in X I get:

dberg@ubuntu:~$ fgconsole
Couldnt get a file descriptor referring to the console
dberg@ubuntu:~$ sudo fgconsole
9
dberg@ubuntu:~$ sudo -u dberg fgconsole
Couldnt get a file descriptor referring to the console
dberg@ubuntu:~$

On both my ubuntu and debian box.

Perhaps its just environment, but why would it work for a non-root
outside X, for root using either su or sudo in X, but not a non-root
in X wether sudo is used or not?

--Dave

Reply to: