1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-26 01:50:16 +02:00

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.
This commit is contained in:
Maarten ter Huurne 2013-08-14 09:03:20 +02:00
parent dfa5413b5b
commit 9c497e7867
3 changed files with 47 additions and 59 deletions

View File

@ -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 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 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 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) #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)); sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &linkApp->consoleApp));
#endif #endif

View File

@ -68,7 +68,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
{ {
manual = ""; manual = "";
file = linkfile; file = linkfile;
dontleave = false;
#ifdef ENABLE_CPUFREQ #ifdef ENABLE_CPUFREQ
setClock(gmenu2x->getDefaultAppClock()); setClock(gmenu2x->getDefaultAppClock());
#endif #endif
@ -133,9 +132,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
} else if (!strncmp(key, "X-OD-Manual", lkey)) { } else if (!strncmp(key, "X-OD-Manual", lkey)) {
manual = buf; manual = buf;
} else if (!strncmp(key, "X-OD-Daemon", lkey)) {
dontleave = !strncmp(val, "true", lval);
} else if (!strncmp(key, "Icon", lkey)) { } else if (!strncmp(key, "Icon", lkey)) {
/* Read the icon from the OPK only /* Read the icon from the OPK only
* if it doesn't exist on the skin */ * if it doesn't exist on the skin */
@ -239,8 +235,6 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
params = value; params = value;
} else if (name == "manual") { } else if (name == "manual") {
manual = value; manual = value;
} else if (name == "dontleave") {
if (value=="true") dontleave = true;
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
} else if (name == "consoleapp") { } else if (name == "consoleapp") {
if (value == "true") consoleApp = true; if (value == "true") consoleApp = true;
@ -339,7 +333,6 @@ bool LinkApp::save() {
if (exec!="" ) f << "exec=" << exec << endl; if (exec!="" ) f << "exec=" << exec << endl;
if (params!="" ) f << "params=" << params << endl; if (params!="" ) f << "params=" << params << endl;
if (manual!="" ) f << "manual=" << manual << endl; if (manual!="" ) f << "manual=" << manual << endl;
if (dontleave ) f << "dontleave=true" << endl;
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
if (consoleApp ) f << "consoleapp=true" << endl; if (consoleApp ) f << "consoleapp=true" << endl;
#endif #endif
@ -656,68 +649,65 @@ void LinkApp::launch(const string &selectedFile, const string &selectedDir) {
if (isOPK) if (isOPK)
command += " ; umount -l " + opkMount; command += " ; umount -l " + opkMount;
#endif #endif
if (dontleave) {
system(command.c_str());
} else {
gmenu2x->saveSelection();
if (selectedFile == "") { gmenu2x->saveSelection();
gmenu2x->writeTmp();
} if (selectedFile == "") {
gmenu2x->writeTmp();
}
#ifdef ENABLE_CPUFREQ #ifdef ENABLE_CPUFREQ
if (clock() != gmenu2x->confInt["menuClock"]) { if (clock() != gmenu2x->confInt["menuClock"]) {
gmenu2x->setClock(clock()); gmenu2x->setClock(clock());
} }
#endif #endif
gmenu2x->quit(); gmenu2x->quit();
/* Make the terminal we're connected to (via stdin/stdout) our /* Make the terminal we're connected to (via stdin/stdout) our
controlling terminal again. Else many console programs are controlling terminal again. Else many console programs are
not going to work correctly. Actually this would not be not going to work correctly. Actually this would not be
necessary, if SDL correctly restored terminal state after necessary, if SDL correctly restored terminal state after
SDL_Quit(). */ SDL_Quit(). */
(void) setsid(); (void) setsid();
ioctl(1, TIOCSCTTY, STDOUT_FILENO); ioctl(1, TIOCSCTTY, STDOUT_FILENO);
(void) dup2(STDOUT_FILENO, 0); (void) dup2(STDOUT_FILENO, 0);
(void) dup2(STDOUT_FILENO, 1); (void) dup2(STDOUT_FILENO, 1);
(void) dup2(STDOUT_FILENO, 2); (void) dup2(STDOUT_FILENO, 2);
if (STDOUT_FILENO > 2) if (STDOUT_FILENO > 2)
close(STDOUT_FILENO); close(STDOUT_FILENO);
int pgid = tcgetpgrp(STDOUT_FILENO); int pgid = tcgetpgrp(STDOUT_FILENO);
signal(SIGTTOU, SIG_IGN); signal(SIGTTOU, SIG_IGN);
tcsetpgrp(STDOUT_FILENO, pgid); tcsetpgrp(STDOUT_FILENO, pgid);
#if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0)
if (consoleApp) { if (consoleApp) {
/* Enable the framebuffer console */ /* Enable the framebuffer console */
char c = '1'; char c = '1';
int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY); int fd = open("/sys/devices/virtual/vtconsole/vtcon1/bind", O_WRONLY);
if (fd < 0) { if (fd < 0) {
WARNING("Unable to open fbcon handle\n"); WARNING("Unable to open fbcon handle\n");
} else { } else {
write(fd, &c, 1); write(fd, &c, 1);
close(fd); 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);
}
} }
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 #endif
execlp("/bin/sh","/bin/sh", "-c", command.c_str(), NULL); 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 //if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
//try relaunching gmenu2x //try relaunching gmenu2x
gmenu2x->main(); gmenu2x->main();
}
} }
const string &LinkApp::getExec() { const string &LinkApp::getExec() {

View File

@ -109,7 +109,6 @@ public:
const std::string &getFile() { return file; } const std::string &getFile() { return file; }
void renameFile(const std::string &name); void renameFile(const std::string &name);
bool &runsInBackgroundRef() { return dontleave; }
}; };
#endif #endif