From: Sasha Levin Subject: [PATCH] kvm tools: Set active console before running /bin/sh Date: Tue, 27 Sep 2011 15:48:52 +0300 Message-ID: <1317127732-463-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@cs.helsinki.fi Return-path: Received: from mail-ey0-f174.google.com ([209.85.215.174]:59793 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549Ab1I0Mtv (ORCPT ); Tue, 27 Sep 2011 08:49:51 -0400 Received: by eya28 with SMTP id 28so4614030eya.19 for ; Tue, 27 Sep 2011 05:49:49 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: 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 --- tools/kvm/guest/init.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/tools/kvm/guest/init.c b/tools/kvm/guest/init.c index 837acfb..b55cd30 100644 --- a/tools/kvm/guest/init.c +++ b/tools/kvm/guest/init.c @@ -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