Navigation


Changeset 1389:de90cf7f381e in freeDiameter for freeDiameterd


Ignore:
Timestamp:
Oct 15, 2019, 11:26:23 PM (4 years ago)
Author:
Thomas Klausner <tk@giga.or.at>
Branch:
default
Phase:
public
Message:

freeDiameterd: add background (daemon) mode

File:
1 edited

Legend:

Unmodified
Added
Removed
  • freeDiameterd/main.c

    r1339 r1389  
    4646#include <syslog.h>
    4747#include <stdarg.h>
     48#include <stdlib.h>
     49#include <unistd.h>
    4850
    4951/* forward declarations */
     
    5355
    5456static char *conffile = NULL;
     57static int daemon_mode = 0;
    5558static int gnutls_debug = 0;
    5659
     
    108111        }
    109112
     113        if (daemon_mode) {
     114                TRACE_DEBUG(INFO, "entering background mode");
     115                CHECK_POSIX_DO( daemon(1, 0), goto error );
     116        }
     117
    110118        /* Initialize the core library */
    111119        ret = fd_core_initialize();
     
    170178                "  used for Authentication, Authorization, and Accounting (AAA).\n");
    171179        printf("\nUsage:  " FD_PROJECT_BINARY " [OPTIONS]...\n");
    172         printf( "  -h, --help             Print help and exit\n"
    173                 "  -V, --version          Print version and exit\n"
    174                 "  -c, --config=filename  Read configuration from this file instead of the \n"
    175                 "                           default location (" DEFAULT_CONF_PATH "/" FD_DEFAULT_CONF_FILENAME ").\n"
     180        printf( "  -h, --help              Print help and exit\n"
     181                "  -V, --version           Print version and exit\n"
     182                "  -c, --config=filename   Read configuration from this file instead of the \n"
     183                "                          default location (" DEFAULT_CONF_PATH "/" FD_DEFAULT_CONF_FILENAME ")\n"
     184                "  -D, --daemon            Start program in background\n"
    176185                "  -s, --syslog            Write log output to syslog (instead of stdout)\n");
    177186        printf( "\nDebug:\n"
    178187                "  These options are mostly useful for developers\n"
    179                 "  -l, --dbglocale         Set the locale for error messages\n"
    180188                "  -d, --debug             Increase verbosity of debug messages if default logger is used\n"
    181                 "  -q, --quiet             Decrease verbosity if default logger is used\n"
     189                "  --dbg_gnutls <int>      Enable GNU TLS debug at level <int>\n"
    182190                "  -f, --dbg_func <func>   Enable all traces within the function <func>\n"
    183191                "  -F, --dbg_file <file.c> Enable all traces within the file <file.c> (basename match)\n"
    184                 "  --dbg_gnutls <int>      Enable GNU TLS debug at level <int>\n"
     192                "  -l, --dbglocale         Set the locale for error messages\n"
     193                "  -q, --quiet             Decrease verbosity if default logger is used\n"
    185194        );
    186195}
     
    198207                { "config",     required_argument,      NULL, 'c' },
    199208                { "syslog",     no_argument,            NULL, 's' },
     209                { "daemon",     no_argument,            NULL, 'D' },
    200210                { "debug",      no_argument,            NULL, 'd' },
    201211                { "quiet",      no_argument,            NULL, 'q' },
     
    209219        /* Loop on arguments */
    210220        while (1) {
    211                 c = getopt_long (argc, argv, "hVc:dql:f:F:g:s", long_options, &option_index);
     221                c = getopt_long (argc, argv, "hVc:Ddql:f:F:g:s", long_options, &option_index);
    212222                if (c == -1)
    213223                        break;  /* Exit from the loop.  */
     
    228238                                }
    229239                                conffile = optarg;
     240                                break;
     241
     242                        case 'D':
     243                                daemon_mode = 1;
    230244                                break;
    231245
Note: See TracChangeset for help on using the changeset viewer.