[PATCH] Use chvt command for tty switching
Vratislav Podzimek
vpodzime at redhat.com
Tue Aug 21 08:32:55 UTC 2012
On Mon, 2012-08-20 at 09:18 -0700, Brian C. Lane wrote:
> On Mon, Aug 20, 2012 at 04:44:35PM +0200, Vratislav Podzimek wrote:
> > isys.vtActivate is problematic when using tmux, chvt command works
> > well and we use it so rarely that it should be okay to call an
> > external command.
> > ---
>
> [snip]
>
> > -def vtActivate (num):
> > - if iutil.isS390():
> > - return
> > - _isys.vtActivate (num)
> > -
> > def isPseudoTTY (fd):
> > return _isys.isPseudoTTY (fd)
>
> [snip]
>
> > +def vtActivate(num):
> > + """
> > + Try to switch to tty number $num.
> > +
> > + @type num: int
> > + @return: whether the switch was successful or not
> > + @rtype: bool
> > +
> > + """
> > +
> > + try:
> > + ret = execWithRedirect("chvt", [num], stdout="/dev/tty5",
> > + stderr="/dev/tty5")
> > + except OSError as oserr:
> > + ret = -1
> > + log.error("Failed to run chvt: %s", oserr.strerror)
> > +
> > + if ret != 0:
> > + log.error("Failed to switch tty to tty%d", num)
> > +
> > + return ret == 0
> > +
>
> Is it safe to drop the isS390() check?
Hard to say, but that's why I added the try-except code for cases chvt
is not installed (may not be available on s390). But if it is available
and installed, I believe it is chvt's business not to do anything bad,
not ours.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list