From: Mathieu Desnoyers Date: Mon, 27 Jan 2014 04:09:41 +0000 (-0500) Subject: lttng-relayd: implement background cmd line option X-Git-Tag: v2.5.0-rc1~239 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b5218ffbf53aa46007927f1e2cda0ad4549abcf9;p=lttng-tools.git lttng-relayd: implement background cmd line option Signed-off-by: Mathieu Desnoyers --- diff --git a/doc/man/lttng-relayd.8 b/doc/man/lttng-relayd.8 index 045ac7a10..4c9217a9c 100644 --- a/doc/man/lttng-relayd.8 +++ b/doc/man/lttng-relayd.8 @@ -50,6 +50,9 @@ There is three debugging level which will print on stderr. Maximum verbosity is .BR "-d, --daemonize" Start as a daemon .TP +.BR "-b, --background" +Start as a daemon, keeping console open +.TP .BR "-C, --control-port" Control port URL (tcp://0.0.0.0:5342 is the default) .TP diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 506bbc6fb..7ac5630fb 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -63,7 +63,7 @@ /* command line options */ char *opt_output_path; -static int opt_daemon; +static int opt_daemon, opt_background; static struct lttng_uri *control_uri; static struct lttng_uri *data_uri; static struct lttng_uri *live_uri; @@ -131,6 +131,7 @@ static struct option long_options[] = { { "data-port", 1, 0, 'D', }, { "live-port", 1, 0, 'L', }, { "daemonize", 0, 0, 'd', }, + { "background", 0, 0, 'b', }, { "group", 1, 0, 'g', }, { "help", 0, 0, 'h', }, { "output", 1, 0, 'o', }, @@ -150,6 +151,7 @@ void usage(void) fprintf(stderr, "Usage: %s OPTIONS\n\nOptions:\n", progname); fprintf(stderr, " -h, --help Display this usage.\n"); fprintf(stderr, " -d, --daemonize Start as a daemon.\n"); + fprintf(stderr, " -b, --background Start as a daemon, keeping console open.\n"); fprintf(stderr, " -C, --control-port URL Control port listening.\n"); fprintf(stderr, " -D, --data-port URL Data port listening.\n"); fprintf(stderr, " -L, --live-port URL Live view port listening.\n"); @@ -210,6 +212,9 @@ int set_option(int opt, const char *arg, const char *optname) case 'd': opt_daemon = 1; break; + case 'b': + opt_background = 1; + break; case 'g': tracing_group_name = strdup(arg); tracing_group_name_override = 1; @@ -2847,8 +2852,8 @@ int main(int argc, char **argv) } /* Daemonize */ - if (opt_daemon) { - ret = daemon(0, 0); + if (opt_daemon || opt_background) { + ret = daemon(0, opt_background); if (ret < 0) { PERROR("daemon"); goto exit;