Changes: Help printings added to Daemon (--help, -h). Invoker's help refactored.

RevBy: Antti Kervinen

Details:
- Added information about single-instance and boot mode.
- Some lines made shorter.
- Descriptions improved.
pull/1/head
Jussi Lind 15 years ago
parent 79098782d4
commit bc29b2541c

@ -393,23 +393,30 @@ static void invoker_send_end(int fd)
// Prints the usage and exits with given status
static void usage(int status)
{
printf("\nUsage: %s [options] [--type=TYPE] [file] [args]\n"
"Launch m or qt application.\n\n"
"TYPE chooses the type of booster used. Qt-booster may be used to launch anything.\n"
"Possible values for TYPE: \n"
" m Launch a MeeGo Touch application.\n"
" qt Launch a Qt application.\n"
printf("\nUsage: %s [options] [--type=TYPE] [file] [args]\n\n"
"Launch m or qt application compiled as a shared library (-shared) or\n"
"a position independent executable (-pie) through %s.\n\n"
"TYPE chooses the type of booster used. Qt-booster may be used to\n"
"launch anything. Possible values for TYPE:\n"
" m Launch a MeeGo Touch application.\n"
" qt Launch a Qt application.\n\n"
"Options:\n"
" -c, --creds Print Aegis security credentials (if enabled).\n"
" -d, --delay SECS After invoking sleep for SECS seconds (default %d).\n"
" -r, --respawn SECS After invoking respawn new booster after SECS seconds (default %d, max %d).\n"
" -w, --wait-term Wait for launched process to terminate (by default).\n"
" -n, --no-wait Do not wait for launched process to terminate.\n"
" -G, --global-syms Places symbols in the application binary and its libraries to\n"
" the global scope. See RTLD_GLOBAL in the dlopen manual page.\n"
" -h, --help Print this help message.\n\n"
" -c, --creds Print Aegis security credentials (if enabled).\n"
" -d, --delay SECS After invoking sleep for SECS seconds\n"
" (default %d).\n"
" -r, --respawn SECS After invoking respawn new booster after SECS seconds\n"
" (default %d, max %d).\n"
" -w, --wait-term Wait for launched process to terminate (default).\n"
" -n, --no-wait Do not wait for launched process to terminate.\n"
" -G, --global-syms Places symbols in the application binary and its\n"
" libraries to the global scope.\n"
" See RTLD_GLOBAL in the dlopen manual page.\n"
" -s, --single-instance Launch the application as a single instance.\n"
" The existing application window will be activated\n"
" if already launched.\n"
" -h, --help Print this help.\n\n"
"Example: %s --type=m /usr/bin/helloworld\n\n",
PROG_NAME_INVOKER, DEFAULT_DELAY, RESPAWN_DELAY, MAX_RESPAWN_DELAY, PROG_NAME_INVOKER);
PROG_NAME_INVOKER, PROG_NAME_LAUNCHER, DEFAULT_DELAY, RESPAWN_DELAY, MAX_RESPAWN_DELAY, PROG_NAME_INVOKER);
exit(status);
}

@ -125,13 +125,20 @@ int main(int argc, char ** argv)
{
// Parse command line
g_debugPrinting = 0;
int helpWanted = 0;
for (int i = 1; i < argc; ++i)
{
if (strcmp(argv[i], "--debug") == 0) g_debugPrinting = 1;
if (strcmp(argv[i], "--debug") == 0)
g_debugPrinting = 1;
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0)
helpWanted = 1;
}
// Preload libraries
loadLibraries(gLibs, sizeof(gLibs) / sizeof(char *));
if (!helpWanted)
loadLibraries(gLibs, sizeof(gLibs) / sizeof(char *));
// Start the real applauncherd.
if (!invokeLauncherLib(argc, argv))

@ -37,6 +37,7 @@
#include <dlfcn.h>
#include <glob.h>
#include <cstring>
#include <cstdio>
Daemon * Daemon::m_instance = NULL;
int Daemon::m_lockFd = -1;
@ -103,11 +104,11 @@ void Daemon::consoleQuiet()
close(2);
if (open("/dev/null", O_RDONLY) < 0)
Logger::logErrorAndDie(EXIT_FAILURE, "Daemon: opening /dev/null readonly");
Logger::logErrorAndDie(EXIT_FAILURE, "Daemon: Failed to open /dev/null as read-only");
int fd = open("/dev/null", O_WRONLY);
if ((fd == -1) || (dup(fd) < 0))
Logger::logErrorAndDie(EXIT_FAILURE, "Daemon: opening /dev/null writeonly");
Logger::logErrorAndDie(EXIT_FAILURE, "Daemon: Failed to open /dev/null as write-only");
}
Daemon * Daemon::instance()
@ -661,7 +662,12 @@ void Daemon::parseArgs(const ArgVect & args)
{
for (ArgVect::const_iterator i(args.begin()); i != args.end(); i++)
{
if ((*i) == "--daemon" || (*i) == "-d")
if ((*i) == "--boot-mode" || (*i) == "-b")
{
Logger::logInfo("Daemon: Boot mode set.");
m_bootMode = true;
}
else if ((*i) == "--daemon" || (*i) == "-d")
{
m_daemon = true;
}
@ -669,18 +675,37 @@ void Daemon::parseArgs(const ArgVect & args)
{
Logger::setDebugMode(true);
}
else if ((*i) == "--quiet" || (*i) == "-q")
else if ((*i) == "--help" || (*i) == "-h")
{
m_quiet = true;
usage(EXIT_SUCCESS);
}
else if ((*i) == "--boot-mode" || (*i) == "-b")
else if ((*i) == "--quiet" || (*i) == "-q")
{
Logger::logInfo("Daemon: Boot mode set.");
m_bootMode = true;
m_quiet = true;
}
}
}
// Prints the usage and exits with given status
void Daemon::usage(int status)
{
printf("\nUsage: %s [options]\n\n"
"Start the application launcher daemon.\n\n"
"Options:\n"
" -b, --boot-mode Start %s in the boot mode. This means that\n"
" boosters will not initialize caches and booster\n"
" respawn delay is set to zero.\n"
" The normal mode is restored by sending SIGUSR1\n"
" to the launcher.\n"
" -d, --daemon Run as %s a daemon.\n"
" --debug Enable debug messages and log everything also to stdout.\n"
" -q, --quiet Close fd's 0, 1 and 2.\n"
" -h, --help Print this help.\n\n",
PROG_NAME_LAUNCHER, PROG_NAME_LAUNCHER, PROG_NAME_LAUNCHER);
exit(status);
}
int Daemon::sigChldPipeFd() const
{
return m_sigChldPipeFd[1];

@ -159,6 +159,9 @@ private:
//! Kill all active boosters with -9
void killBoosters();
//! Prints the usage and exits with given status
void usage(int status);
//! Daemonize flag (--fork). Daemon forks if true.
bool m_daemon;

Loading…
Cancel
Save