Mercurial > hg > toybox
comparison toys/pending/init.c @ 1187:18cc63376e66 draft
init: don't use VT_OPENQRY.
The original codepath checks if there is a VT available,
and if there isn't sets TERM to vt102 (unless TERM is set to something
other than "linux").
Otherwise, TERM is set to "linux" if it is not already set.
However, we can rely on getty/... to set TERM if "linux" is not suitable.
This has the benefit of dropping a slightly messy section.
author | Isaac Dunham <ibid.ag@gmail.com> |
---|---|
date | Tue, 28 Jan 2014 17:46:14 -0600 |
parents | 2a4f1dc494d0 |
children | 6ca31490f581 |
comparison
equal
deleted
inserted
replaced
1186:8b62561ce52a | 1187:18cc63376e66 |
---|---|
15 | 15 |
16 init the system. | 16 init the system. |
17 */ | 17 */ |
18 | 18 |
19 #include "toys.h" | 19 #include "toys.h" |
20 #include <linux/vt.h> | |
21 #include <sys/reboot.h> | 20 #include <sys/reboot.h> |
22 | 21 |
23 struct action_list_seed { | 22 struct action_list_seed { |
24 struct action_list_seed *next; | 23 struct action_list_seed *next; |
25 pid_t pid; | 24 pid_t pid; |
58 dup2(fd,1); | 57 dup2(fd,1); |
59 dup2(fd,2); | 58 dup2(fd,2); |
60 } | 59 } |
61 } | 60 } |
62 | 61 |
63 p = getenv("TERM"); | 62 if (!getenv("TERM")) putenv("TERM=linux"); |
64 #ifdef VT_OPENQRY | |
65 int terminal_no; | |
66 if (ioctl(0, VT_OPENQRY, &terminal_no)) { | |
67 if (!p || !strcmp(p,"linux")) putenv("TERM=vt102"); | |
68 } else | |
69 #endif | |
70 if (!p) putenv("TERM=linux"); | |
71 } | 63 } |
72 | 64 |
73 static void set_sane_term(void) | 65 static void set_sane_term(void) |
74 { | 66 { |
75 struct termios terminal; | 67 struct termios terminal; |