From: "D. Matt Placek" <dmattplacek@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] ioctl interface to wait on VT switch
Date: Wed, 25 Mar 2009 12:51:44 -0400 [thread overview]
Message-ID: <8044b6ad0903250951w3b843e6etd6ec866404dbe455@mail.gmail.com> (raw)
This is a patch to the 2.6.29 kernel which adds an ioctl to the VT
interface which allows an application to wait on any VT switch, rather
than having to wait on switching to a specific VT. This would be a
big help for the ConsoleKit, which currently creates 60+ threads where
each thread is asleep waiting for a switch to one of every possible
VT. It would be great if we could get this included in the kernel- or
if there is a better approach feedback is invited. It would simply be
nice not to have to spawn 60 threads just to wait for a console
switch, and this is a pretty minor addition to the VT system.
diff -U 3 -r linux-2.6.29-rc8/drivers/char/vt_ioctl.c
patched-linux-2.6.29-rc8/drivers/char/vt_ioctl.c
--- linux-2.6.29-rc8/drivers/char/vt_ioctl.c 2009-03-12 22:39:28.000000000 -0400
+++ patched-linux-2.6.29-rc8/drivers/char/vt_ioctl.c 2009-03-25
12:35:42.000000000 -0400
@@ -41,6 +41,8 @@
#define VT_IS_IN_USE(i) (console_driver->ttys[i] &&
console_driver->ttys[i]->count)
#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console ||
vc_cons[i].d == sel_cons)
+#define WAIT_ANY_CONSOLE -1234
+
/*
* Console (vt and kd) routines, as defined by USL SVR4 manual, and by
* experimentation and study of X386 SYSV handling.
@@ -846,6 +848,13 @@
ret = vt_waitactive(arg - 1);
break;
+
+ case VT_WAITSWITCH:
+ if (!perm)
+ goto eperm;
+ ret = vt_waitactive(WAIT_ANY_CONSOLE);
+ break;
+
/*
* If a vt is under process control, the kernel will not switch to it
* immediately, but postpone the operation until the process calls this
@@ -1202,6 +1211,11 @@
if (signal_pending(current))
break;
schedule();
+
+ if (vt == WAIT_ANY_CONSOLE) {
+ retval = 0;
+ break;
+ }
}
remove_wait_queue(&vt_activate_queue, &wait);
__set_current_state(TASK_RUNNING);
diff -U 3 -r linux-2.6.29-rc8/include/linux/vt.h
patched-linux-2.6.29-rc8/include/linux/vt.h
--- linux-2.6.29-rc8/include/linux/vt.h 2009-03-12 22:39:28.000000000 -0400
+++ patched-linux-2.6.29-rc8/include/linux/vt.h 2009-03-24
11:16:31.000000000 -0400
@@ -73,5 +73,6 @@
#define VT_LOCKSWITCH 0x560B /* disallow vt switching */
#define VT_UNLOCKSWITCH 0x560C /* allow vt switching */
#define VT_GETHIFONTMASK 0x560D /* return hi font mask */
+#define VT_WAITSWITCH 0x560E /* wait for change in active vt */
#endif /* _LINUX_VT_H */
next reply other threads:[~2009-03-25 16:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 16:51 D. Matt Placek [this message]
2009-03-25 17:44 ` Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8044b6ad0903250951w3b843e6etd6ec866404dbe455@mail.gmail.com \
--to=dmattplacek@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®