svn commit: trunk/busybox/console-tools
vda at busybox.net
vda at busybox.net
Fri Apr 18 20:44:46 PDT 2008
Author: vda
Date: 2008-04-18 20:44:45 -0700 (Fri, 18 Apr 2008)
New Revision: 21763
Log:
openvt: handle -ws correctly. By James Simmons <jsimmons AT infradead.org>
function old new delta
openvt_main 343 429 +86
Modified:
trunk/busybox/console-tools/openvt.c
Changeset:
Modified: trunk/busybox/console-tools/openvt.c
===================================================================
--- trunk/busybox/console-tools/openvt.c 2008-04-19 03:42:47 UTC (rev 21762)
+++ trunk/busybox/console-tools/openvt.c 2008-04-19 03:44:45 UTC (rev 21763)
@@ -107,6 +107,7 @@
int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
char vtname[sizeof(VC_FORMAT) + sizeof(int)*3];
+ struct vt_stat vtstat;
char *str_c;
int vtno;
int flags;
@@ -137,6 +138,7 @@
close(0);
/*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */
xopen(vtname, O_RDWR);
+ xioctl(0, VT_GETSTATE, &vtstat);
if (flags & OPT_s) {
xioctl(0, VT_ACTIVATE, (void*)(ptrdiff_t)vtno);
@@ -163,9 +165,16 @@
vfork_child(argv);
if (flags & OPT_w) {
- wait(NULL);
-// TODO: -ws handling should be here
+ /* We have only one child, wait for it */
+ safe_waitpid(-1, NULL, 0); /* loops on EINTR */
+ if (flags & OPT_s) {
+ xioctl(0, VT_ACTIVATE, (void*)(ptrdiff_t)(vtstat.v_active));
+ xioctl(0, VT_WAITACTIVE, (void*)(ptrdiff_t)(vtstat.v_active));
+ // Compat: even with -c N (try to) disallocate:
+ // # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5
+ // openvt: could not deallocate console 9
+ xioctl(0, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno);
+ }
}
-
return EXIT_SUCCESS;
}
More information about the busybox-cvs
mailing list