rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / desktop / lightdm / patches / 14-vt-switch.patch
bloba23fbc060a3be7af2ccafcdfffca54ae6da933f3
1 --- lightdm-1.19.3/src/lightdm.c.1 2016-11-30 11:16:46.549436459 +0300
2 +++ lightdm-1.19.3/src/lightdm.c 2016-11-30 11:19:57.426432236 +0300
3 @@ -20,6 +20,7 @@
4 #include <fcntl.h>
5 #include <sys/stat.h>
6 #include <errno.h>
7 +#include <sys/vt.h>
9 #include "configuration.h"
10 #include "display-manager.h"
11 @@ -174,9 +174,55 @@
15 +static int
16 +open_a_console (char *fnam)
18 + int fd;
20 + fd = open (fnam, O_RDONLY | O_NOCTTY);
21 + if (fd < 0 && errno == EACCES)
22 + fd = open (fnam, O_WRONLY | O_NOCTTY);
24 + if (fd < 0)
25 + return -1;
27 + if (! isatty(fd)) {
28 + close (fd);
29 + fd = -1;
30 + }
32 + return fd;
35 +static void
36 +switch_vt_console()
38 + int fd;
40 + /* Switch to VT1 before going down. */
41 + fd = open_a_console ("/dev/vt/active");
42 + if (fd < 0) {
43 + fd = open_a_console ("/dev/vt/0");
44 + }
46 + if (fd >= 0) {
47 + int res;
49 + res = ioctl (fd, VT_ACTIVATE, 1);
51 + if (res != 0) {
52 + if (errno == ENOTSUP) {
53 + g_debug ("VT_ENABLE not supported, cannot switch to VT1");
54 + }
55 + }
56 + }
59 static void
60 display_manager_stopped_cb (DisplayManager *display_manager)
62 + g_debug ("Switching VT to VT1 before going down");
63 + switch_vt_console();
64 g_debug ("Stopping daemon");
65 g_main_loop_quit (loop);