[PATCH v2] kvm tools: Set active console before running /bin/sh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch sets active console to the serial console before running the
shell. Doing so fixes two issues:

* Fix job control.

* Set all env vars.

The user visible issues are less warnings (no more of this:
  sh: cannot set terminal process group (-1): Inappropriate ioctl for device
  sh: no job control in this shell)

A working 'top', and a working ctrl-c.

Signed-off-by: Sasha Levin <levinsasha928@xxxxxxxxx>
---
 tools/kvm/guest/init.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/guest/init.c b/tools/kvm/guest/init.c
index 837acfb..4fc6aaf 100644
--- a/tools/kvm/guest/init.c
+++ b/tools/kvm/guest/init.c
@@ -11,7 +11,7 @@
 static int run_process(char *filename)
 {
 	char *new_argv[] = { filename, NULL };
-	char *new_env[] = { NULL };
+	char *new_env[] = { "TERM=linux" };
 
 	return execve(filename, new_argv, new_env);
 }
@@ -30,6 +30,12 @@ int main(int argc, char *argv[])
 
 	do_mounts();
 
+        /* get session leader */
+        setsid();
+
+        /* set controlling terminal */
+        ioctl (0, TIOCSCTTY, 1);
+
 	puts("Starting '/bin/sh'...");
 
 	run_process("/bin/sh");
-- 
1.7.6.1

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux