Mercurial > hg > toybox
annotate toys/other/chvt.c @ 1727:c0ef9b7976f0 draft
Use xsignal() instead of signal().
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 10 Mar 2015 11:07:28 -0500 |
parents | 8b62561ce52a |
children | 57f2a26fa92c |
rev | line source |
---|---|
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
1 /* chvt.c - switch virtual terminals |
244
e6273440c9c0
Comment and whitespace cleanups by Charlie Shepherd (code's the same).
Rob Landley <rob@landley.net>
parents:
234
diff
changeset
|
2 * |
229 | 3 * Copyright (C) 2008 David Anders <danders@amltd.com> |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
229
diff
changeset
|
4 |
234
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
5 USE_CHVT(NEWTOY(chvt, "<1", TOYFLAG_USR|TOYFLAG_SBIN)) |
163498bf547b
Move NEWTOY() list from end of toylist.h to generated/newtoys.h.
Rob Landley <rob@landley.net>
parents:
233
diff
changeset
|
6 |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
229
diff
changeset
|
7 config CHVT |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
8 bool "chvt" |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
9 default y |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
10 help |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
11 usage: chvt N |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
229
diff
changeset
|
12 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
13 Change to virtual terminal number N. (This only works in text mode.) |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
229
diff
changeset
|
14 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
15 Virtual terminals are the Linux VGA text mode displays, ordinarily |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
16 switched between via alt-F1, alt-F2, etc. Use ctrl-alt-F1 to switch |
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
17 from X to a virtual terminal, and alt-F6 (or F7, or F8) to get back. |
233
d4176f3f3835
Zap toys/Config.in and instead create generated/Config.in from contents of
Rob Landley <rob@landley.net>
parents:
229
diff
changeset
|
18 */ |
229 | 19 |
20 #include "toys.h" | |
21 | |
22 void chvt_main(void) | |
23 { | |
1186
8b62561ce52a
Two changes to shut up GCC:
Isaac Dunham <ibid.ag@gmail.com>
parents:
1085
diff
changeset
|
24 int vtnum, fd = fd; |
1085 | 25 char *consoles[]={"/dev/console", "/dev/vc/0", "/dev/tty", NULL}, **cc; |
229 | 26 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
27 vtnum=atoi(*toys.optargs); |
1085 | 28 for (cc = consoles; *cc; cc++) |
29 if (-1 != (fd = open(*cc, O_RDWR))) break; | |
229 | 30 |
694
786841fdb1e0
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents:
656
diff
changeset
|
31 // These numbers are VT_ACTIVATE and VT_WAITACTIVE from linux/vt.h |
1085 | 32 if (!*cc || fd < 0 || ioctl(fd, 0x5606, vtnum) || ioctl(fd, 0x5607, vtnum)) |
33 perror_exit(0); | |
229 | 34 } |