From 9c497e7867418bb3377b492033d090fc0f82bcb9 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Wed, 14 Aug 2013 09:03:20 +0200 Subject: [PATCH] Remove "don't leave" feature If the application in question daemonizes, it will continue running no matter whether we start it with system() or execlp(). So I don't see a reason for this feature to exist and removing it means less code paths to worry about. --- src/gmenu2x.cpp | 1 - src/linkapp.cpp | 104 ++++++++++++++++++++++-------------------------- src/linkapp.h | 1 - 3 files changed, 47 insertions(+), 59 deletions(-) diff --git a/src/gmenu2x.cpp b/src/gmenu2x.cpp index fdd2202..2be87ad 100644 --- a/src/gmenu2x.cpp +++ b/src/gmenu2x.cpp @@ -899,7 +899,6 @@ void GMenu2X::editLink() { sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon)); sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens)); sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases)); - sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &linkApp->runsInBackgroundRef())); #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &linkApp->consoleApp)); #endif diff --git a/src/linkapp.cpp b/src/linkapp.cpp index 2655de8..d32fa72 100644 --- a/src/linkapp.cpp +++ b/src/linkapp.cpp @@ -68,7 +68,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_, { manual = ""; file = linkfile; - dontleave = false; #ifdef ENABLE_CPUFREQ setClock(gmenu2x->getDefaultAppClock()); #endif @@ -133,9 +132,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_, } else if (!strncmp(key, "X-OD-Manual", lkey)) { manual = buf; - } else if (!strncmp(key, "X-OD-Daemon", lkey)) { - dontleave = !strncmp(val, "true", lval); - } else if (!strncmp(key, "Icon", lkey)) { /* Read the icon from the OPK only * if it doesn't exist on the skin */ @@ -239,8 +235,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_, params = value; } else if (name == "manual") { manual = value; - } else if (name == "dontleave") { - if (value=="true") dontleave = true; #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) } else if (name == "consoleapp") { if (value == "true") consoleApp = true; @@ -339,7 +333,6 @@ bool LinkApp::save() { if (exec!="" ) f << "exec=" << exec << endl; if (params!="" ) f << "params=" << params << endl; if (manual!="" ) f << "manual=" << manual << endl; - if (dontleave ) f << "dontleave=true" << endl; #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) if (consoleApp ) f << "consoleapp=true" << endl; #endif @@ -656,68 +649,65 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) { if (isOPK) command += " ; umount -l " + opkMount; #endif - if (dontleave) { - system(command.c_str()); - } else { - gmenu2x->saveSelection(); - if (selectedFile == "") { - gmenu2x->writeTmp(); - } + gmenu2x->saveSelection(); + + if (selectedFile == "") { + gmenu2x->writeTmp(); + } #ifdef ENABLE_CPUFREQ - if (clock() != gmenu2x->confInt["menuClock"]) { - gmenu2x->setClock(clock()); - } + if (clock() != gmenu2x->confInt["menuClock"]) { + gmenu2x->setClock(clock()); + } #endif - gmenu2x->quit(); + gmenu2x->quit(); - /* Make the terminal we're connected to (via stdin/stdout) our - controlling 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(). */ - (void) setsid(); + /* Make the terminal we're connected to (via stdin/stdout) our + controlling 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(). */ + (void) setsid(); - ioctl(1, TIOCSCTTY, STDOUT_FILENO); - (void) dup2(STDOUT_FILENO, 0); - (void) dup2(STDOUT_FILENO, 1); - (void) dup2(STDOUT_FILENO, 2); + ioctl(1, TIOCSCTTY, STDOUT_FILENO); + (void) dup2(STDOUT_FILENO, 0); + (void) dup2(STDOUT_FILENO, 1); + (void) dup2(STDOUT_FILENO, 2); - if (STDOUT_FILENO > 2) - close(STDOUT_FILENO); + if (STDOUT_FILENO > 2) + close(STDOUT_FILENO); - int pgid = tcgetpgrp(STDOUT_FILENO); - signal(SIGTTOU, SIG_IGN); - tcsetpgrp(STDOUT_FILENO, pgid); + int pgid = tcgetpgrp(STDOUT_FILENO); + signal(SIGTTOU, SIG_IGN); + tcsetpgrp(STDOUT_FILENO, pgid); #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) - if (consoleApp) { - /* Enable the framebuffer console */ - char c = '1'; - int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY); - if (fd < 0) { - WARNING("Unable to open fbcon handle\n"); - } else { - write(fd, &c, 1); - close(fd); - } - - fd = open("/dev/tty1", O_RDWR); - if (fd < 0) { - WARNING("Unable to open tty1 handle\n"); - } else { - if (ioctl(fd, VT_ACTIVATE, 1) < 0) - WARNING("Unable to activate tty1\n"); - close(fd); - } + if (consoleApp) { + /* Enable the framebuffer console */ + char c = '1'; + int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY); + if (fd < 0) { + WARNING("Unable to open fbcon handle\n"); + } else { + write(fd, &c, 1); + close(fd); } + + fd = open("/dev/tty1", O_RDWR); + if (fd < 0) { + WARNING("Unable to open tty1 handle\n"); + } else { + if (ioctl(fd, VT_ACTIVATE, 1) < 0) + WARNING("Unable to activate tty1\n"); + close(fd); + } + } #endif - 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 - gmenu2x->main(); - } + 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 + gmenu2x->main(); } const string &LinkApp::getExec() { diff --git a/src/linkapp.h b/src/linkapp.h index f11a291..4807cf3 100644 --- a/src/linkapp.h +++ b/src/linkapp.h @@ -109,7 +109,6 @@ public: const std::string &getFile() { return file; } void renameFile(const std::string &name); - bool &runsInBackgroundRef() { return dontleave; } }; #endif