blob: 7c2814d1c1e885a713aa72cf269dd4867487cde1 [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersen0460ff21999-10-25 23:32:44 +00002/*
Eric Andersen28672dd2003-10-22 10:30:53 +00003 * Mini chvt implementation for busybox
Eric Andersen0460ff21999-10-25 23:32:44 +00004 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Eric Andersen28672dd2003-10-22 10:30:53 +00006 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02007 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
Eric Andersen0460ff21999-10-25 23:32:44 +00008 */
Denys Vlasenko6d932992016-11-23 10:39:27 +01009//config:config CHVT
Denys Vlasenko4eed2c62017-07-18 22:01:24 +020010//config: bool "chvt (2 kb)"
Denys Vlasenko6d932992016-11-23 10:39:27 +010011//config: default y
Denys Vlasenko6d932992016-11-23 10:39:27 +010012//config: help
Denys Vlasenko72089cf2017-07-21 09:50:55 +020013//config: This program is used to change to another terminal.
14//config: Example: chvt 4 (change to terminal /dev/tty4)
Denys Vlasenko6d932992016-11-23 10:39:27 +010015
Denys Vlasenkoff53bee2017-08-05 02:02:31 +020016//applet:IF_CHVT(APPLET_NOEXEC(chvt, chvt, BB_DIR_USR_BIN, BB_SUID_DROP, chvt))
Denys Vlasenko6d932992016-11-23 10:39:27 +010017
18//kbuild:lib-$(CONFIG_CHVT) += chvt.o
Pere Orga55068c42011-03-27 23:42:28 +020019
20//usage:#define chvt_trivial_usage
21//usage: "N"
22//usage:#define chvt_full_usage "\n\n"
23//usage: "Change the foreground virtual terminal to /dev/ttyN"
24
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000025#include "libbb.h"
Eric Andersenbd22ed82000-07-08 18:55:24 +000026
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000027int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denys Vlasenkoe992bae2009-11-28 15:18:53 +010028int chvt_main(int argc UNUSED_PARAM, char **argv)
Eric Andersen0460ff21999-10-25 23:32:44 +000029{
Denys Vlasenkoe992bae2009-11-28 15:18:53 +010030 int num = xatou_range(single_argv(argv), 1, 63);
Denis Vlasenko2afd5ab2008-08-05 23:32:27 +000031 console_make_active(get_console_fd_or_die(), num);
Matt Kraai3e856ce2000-12-01 02:55:13 +000032 return EXIT_SUCCESS;
Eric Andersen0460ff21999-10-25 23:32:44 +000033}