From de02a8802c9364fee397403f4151ad3838185295 Mon Sep 17 00:00:00 2001 From: Fabien Thomas Date: Thu, 17 Aug 2006 07:30:55 +0000 Subject: [PATCH] add command line support with: launch as a foreground application, do not set priority git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1219 fd59a12c-fef9-0310-b244-a6a79926bd2f --- exec/main.c | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/exec/main.c b/exec/main.c index 386c6435..a68724c0 100644 --- a/exec/main.c +++ b/exec/main.c @@ -245,7 +245,6 @@ static void aisexec_mempool_init (void) static void aisexec_tty_detach (void) { -#ifndef DEBUG /* * Disconnect from TTY if this is not a debug run */ @@ -262,7 +261,6 @@ static void aisexec_tty_detach (void) exit (0); break; } -#endif } static void aisexec_setscheduler (void) @@ -377,11 +375,36 @@ int main (int argc, char **argv) struct config_iface_ver0 *config; void *config_p; char *config_iface; - int res; + int res, ch; + int background, setprio; int totem_log_service; log_init ("MAIN"); - aisexec_tty_detach (); + /* default configuration + */ + background = 1; + setprio = 1; + + while ((ch = getopt (argc, argv, "fp")) != EOF) { + + switch (ch) { + case 'f': + background = 0; + break; + case 'p': + setprio = 0; + break; + default: + fprintf(stderr, \ + "usage:\n"\ + " -F : Start application in foreground.\n"\ + " -P : Do not set process priority. \n"); + return EXIT_FAILURE; + } + } + + if (background) + aisexec_tty_detach (); log_printf (LOG_LEVEL_NOTICE, "AIS Executive Service RELEASE '%s'\n", RELEASE_VERSION); log_printf (LOG_LEVEL_NOTICE, "Copyright (C) 2002-2006 MontaVista Software, Inc and contributors.\n"); @@ -493,7 +516,8 @@ int main (int argc, char **argv) * Lock all memory to avoid page faults which may interrupt * application healthchecking */ - aisexec_setscheduler (); + if (setprio) + aisexec_setscheduler (); aisexec_mlockall (); @@ -569,5 +593,5 @@ int main (int argc, char **argv) */ poll_run (aisexec_poll_handle); - return (0); + return EXIT_SUCCESS; }