Date:2011-10-23 13:03:11 (12 years 5 months ago)
Author:Maarten ter Huurne
Commit:14bae043c08c3c3776bed11065f058757d3563f4
Message:LinkApp: various cleanups.

Log a warning message if setsid() fails.
Also improved code layout.
Files: src/linkapp.cpp (1 diff)

Change Details

src/linkapp.cpp
458458    if (dontleave) {
459459        system(command.c_str());
460460    } else {
461        if (gmenu2x->confInt["saveSelection"] && (gmenu2x->confInt["section"]!=gmenu2x->menu->selSectionIndex() || gmenu2x->confInt["link"]!=gmenu2x->menu->selLinkIndex()))
461        if (gmenu2x->confInt["saveSelection"] && (
462                gmenu2x->confInt["section"]!=gmenu2x->menu->selSectionIndex()
463                || gmenu2x->confInt["link"]!=gmenu2x->menu->selLinkIndex()
464        )) {
462465            gmenu2x->writeConfig();
466        }
463467
464468#ifdef PLATFORM_GP2X
465        if (gmenu2x->fwType == "open2x" && gmenu2x->savedVolumeMode != gmenu2x->volumeMode)
469        if (gmenu2x->fwType == "open2x"
470                && gmenu2x->savedVolumeMode != gmenu2x->volumeMode) {
466471            gmenu2x->writeConfigOpen2x();
472        }
467473#endif
468474
469        if (selectedFile=="")
475        if (selectedFile == "") {
470476            gmenu2x->writeTmp();
471             gmenu2x->quit();
472        if (clock()!=gmenu2x->confInt["menuClock"])
477        }
478        if (clock() != gmenu2x->confInt["menuClock"]) {
473479            gmenu2x->setClock(clock());
480        }
481        gmenu2x->quit();
474482        //if (gamma()!=0 && gamma()!=gmenu2x->confInt["gamma"])
475483        // gmenu2x->setGamma(gamma());
476484
477485        /* Make the terminal we're connected to (via stdin/stdout) our
478                 contolling terminal again. Else many console programs are
479                 not going to work correctly. Actually this would not be
480                 necessary, if SDL correctly restored terminal state after
481                 SDL_Quit(). */
482        int pid = setsid();
486           controlling terminal again. Else many console programs are
487           not going to work correctly. Actually this would not be
488           necessary, if SDL correctly restored terminal state after
489           SDL_Quit(). */
490        pid_t pid = setsid();
491        if (pid == (pid_t)-1) {
492            WARNING("Failed to create new process group\n");
493        }
483494        ioctl(1, TIOCSCTTY, STDOUT_FILENO);
484495
485496        int pgid = tcgetpgrp(STDOUT_FILENO);
486497        signal(SIGTTOU, SIG_IGN);
487498        tcsetpgrp(STDOUT_FILENO, pgid);
488499
489        execlp("/bin/sh","/bin/sh","-c",command.c_str(),NULL);
500        execlp("/bin/sh","/bin/sh", "-c", command.c_str(), NULL);
490501        //if execution continues then something went wrong and as we already called SDL_Quit we cannot continue
491502        //try relaunching gmenu2x
492503        chdir(gmenu2x->getExePath().c_str());
493504        execlp("./gmenu2x", "./gmenu2x", NULL);
494505    }
495506
496
497507    chdir(gmenu2x->getExePath().c_str());
498508}
499509

Archive Download the corresponding diff file



interactive