mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 12:30:18 +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:
parent
dfa5413b5b
commit
9c497e7867
@ -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
|
||||
|
104
src/linkapp.cpp
104
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() {
|
||||
|
@ -109,7 +109,6 @@ public:
|
||||
|
||||
const std::string &getFile() { return file; }
|
||||
void renameFile(const std::string &name);
|
||||
bool &runsInBackgroundRef() { return dontleave; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user