From dd0709e1da6fec7758bb6f093a98f2db00336077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20K=C3=BChling?= Date: Sun, 26 Dec 2010 17:58:22 +0100 Subject: [PATCH] Fix problems with missing tty for launched applications --- src/linkapp.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/linkapp.cpp b/src/linkapp.cpp index 2e3edf6..2cdcd10 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include #include +#include #include #include @@ -492,6 +493,15 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) { if((backlight() != 0) && (backlight() != gmenu2x->confInt["backlight"])) gmenu2x->setBacklight(backlight()); + /* Make the terminal we're connected to (via stdin/stdout) our + contolling terminal again. Else many console programs are + not going to work correctly. Actually this would not be + necessary, if SDL correctly restored terminal state after + SDL_Quit(). */ + int pid = setsid(); + tcsetpgrp(1, pid); + ioctl(1, TIOCSCTTY, (char *)1); + execlp("/bin/sh","/bin/sh","-c",command.c_str(),NULL); //if execution continues then something went wrong and as we already called SDL_Quit we cannot continue //try relaunching gmenu2x