diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-19 03:44:45 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-19 03:44:45 +0000 |
commit | 1b2d0b28213d7f0cc03cb9546fa41318c95f6215 (patch) | |
tree | 0714625a9f7b0d8d119467d0f134cdb41c674b7d /console-tools/openvt.c | |
parent | 50d068cb76baa7d37b948d021d3b16e2798ed7cf (diff) | |
download | busybox-w32-1b2d0b28213d7f0cc03cb9546fa41318c95f6215.tar.gz busybox-w32-1b2d0b28213d7f0cc03cb9546fa41318c95f6215.tar.bz2 busybox-w32-1b2d0b28213d7f0cc03cb9546fa41318c95f6215.zip |
openvt: handle -ws correctly. By James Simmons <jsimmons AT infradead.org>
function old new delta
openvt_main 343 429 +86
Diffstat (limited to 'console-tools/openvt.c')
-rw-r--r-- | console-tools/openvt.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/console-tools/openvt.c b/console-tools/openvt.c index 6f2aa19c4..3bb0a9210 100644 --- a/console-tools/openvt.c +++ b/console-tools/openvt.c | |||
@@ -107,6 +107,7 @@ int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | |||
107 | int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv) | 107 | int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv) |
108 | { | 108 | { |
109 | char vtname[sizeof(VC_FORMAT) + sizeof(int)*3]; | 109 | char vtname[sizeof(VC_FORMAT) + sizeof(int)*3]; |
110 | struct vt_stat vtstat; | ||
110 | char *str_c; | 111 | char *str_c; |
111 | int vtno; | 112 | int vtno; |
112 | int flags; | 113 | int flags; |
@@ -137,6 +138,7 @@ int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
137 | close(0); | 138 | close(0); |
138 | /*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */ | 139 | /*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */ |
139 | xopen(vtname, O_RDWR); | 140 | xopen(vtname, O_RDWR); |
141 | xioctl(0, VT_GETSTATE, &vtstat); | ||
140 | 142 | ||
141 | if (flags & OPT_s) { | 143 | if (flags & OPT_s) { |
142 | xioctl(0, VT_ACTIVATE, (void*)(ptrdiff_t)vtno); | 144 | xioctl(0, VT_ACTIVATE, (void*)(ptrdiff_t)vtno); |
@@ -163,9 +165,16 @@ int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
163 | 165 | ||
164 | vfork_child(argv); | 166 | vfork_child(argv); |
165 | if (flags & OPT_w) { | 167 | if (flags & OPT_w) { |
166 | wait(NULL); | 168 | /* We have only one child, wait for it */ |
167 | // TODO: -ws handling should be here | 169 | safe_waitpid(-1, NULL, 0); /* loops on EINTR */ |
170 | if (flags & OPT_s) { | ||
171 | xioctl(0, VT_ACTIVATE, (void*)(ptrdiff_t)(vtstat.v_active)); | ||
172 | xioctl(0, VT_WAITACTIVE, (void*)(ptrdiff_t)(vtstat.v_active)); | ||
173 | // Compat: even with -c N (try to) disallocate: | ||
174 | // # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5 | ||
175 | // openvt: could not deallocate console 9 | ||
176 | xioctl(0, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno); | ||
177 | } | ||
168 | } | 178 | } |
169 | |||
170 | return EXIT_SUCCESS; | 179 | return EXIT_SUCCESS; |
171 | } | 180 | } |