[PATCH 2/3] linux: xf86OpenConsole: open vt before detaching from terminal
Hans de Goede
hdegoede at redhat.com
Thu Jan 16 02:24:50 PST 2014
This is a preparation patch for automatically doing keeptty when the server
gets passed the current vt as vt to use on the cmdline.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
hw/xfree86/os-support/linux/lnx_init.c | 43 ++++++++++++++++------------------
1 file changed, 20 insertions(+), 23 deletions(-)
diff --git a/hw/xfree86/os-support/linux/lnx_init.c b/hw/xfree86/os-support/linux/lnx_init.c
index bead72e..5f7d39b 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -126,27 +126,6 @@ xf86OpenConsole(void)
xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
- if (!KeepTty) {
- pid_t ppid = getppid();
- pid_t ppgid;
-
- ppgid = getpgid(ppid);
-
- /*
- * change to parent process group that pgid != pid so
- * that setsid() doesn't fail and we become process
- * group leader
- */
- if (setpgid(0, ppgid) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
- strerror(errno));
-
- /* become process group leader */
- if ((setsid() < 0))
- xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
- strerror(errno));
- }
-
i = 0;
while (vcs[i] != NULL) {
snprintf(vtname, sizeof(vtname), vcs[i], xf86Info.vtno); /* /dev/tty1-64 */
@@ -170,8 +149,26 @@ xf86OpenConsole(void)
else
activeVT = vts.v_active;
-#if 0
if (!KeepTty) {
+ pid_t ppid = getppid();
+ pid_t ppgid;
+
+ ppgid = getpgid(ppid);
+
+ /*
+ * change to parent process group that pgid != pid so
+ * that setsid() doesn't fail and we become process
+ * group leader
+ */
+ if (setpgid(0, ppgid) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: setpgid failed: %s\n",
+ strerror(errno));
+
+ /* become process group leader */
+ if ((setsid() < 0))
+ xf86Msg(X_WARNING, "xf86OpenConsole: setsid failed: %s\n",
+ strerror(errno));
+#if 0
/*
* Detach from the controlling tty to avoid char loss
*/
@@ -179,8 +176,8 @@ xf86OpenConsole(void)
SYSCALL(ioctl(i, TIOCNOTTY, 0));
close(i);
}
- }
#endif
+ }
if (!xf86Info.ShareVTs) {
struct termios nTty;
--
1.8.4.2
More information about the xorg-devel
mailing list