From: Marius Vlad Date: Tue, 20 Apr 2021 11:19:08 +0000 (+0300) Subject: main: Copy cmd line args and print them X-Git-Tag: 11.91.0~1 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=65361f9f797905679c6c58c58733036911d54f7e;p=src%2Fagl-compositor.git main: Copy cmd line args and print them This makes it really easy to spot on what arguments have been passed to the compositor. When a test client will run the compositor this will be helpful to verify that we pass the correct arguments. Fixes a small typo along the way. Bug-AGL: SPEC-3880 Signed-off-by: Marius Vlad Change-Id: Ia4198ce6bff465f479cf9a0a87c17998c5548868 --- diff --git a/src/main.c b/src/main.c index 5605841..126b938 100644 --- a/src/main.c +++ b/src/main.c @@ -1520,8 +1520,9 @@ usage(int error_code) "Usage: agl-compositor [OPTIONS]\n" "\n" "This is " PACKAGE_STRING ", the reference compositor for\n" - "Automotive Grade Linux. Weston-ivi supports multiple backends, and depending\n" - "on which backend is in use different options will be accepted.\n" + "Automotive Grade Linux. " PACKAGE_STRING " supports multiple " + "backends,\nand depending on which backend is in use different " + "options will be accepted.\n" "\n" "Core options:\n" "\n" @@ -1541,9 +1542,30 @@ usage(int error_code) exit(error_code); } +static char * +copy_command_line(int argc, char * const argv[]) +{ + FILE *fp; + char *str = NULL; + size_t size = 0; + int i; + + fp = open_memstream(&str, &size); + if (!fp) + return NULL; + + fprintf(fp, "%s", argv[0]); + for (i = 1; i < argc; i++) + fprintf(fp, " %s", argv[i]); + fclose(fp); + + return str; +} + int main(int argc, char *argv[]) { struct ivi_compositor ivi = { 0 }; + char *cmdline; struct wl_display *display = NULL; struct wl_event_loop *loop; struct wl_event_source *signals[3] = { 0 }; @@ -1588,6 +1610,7 @@ int main(int argc, char *argv[]) /* Prevent any clients we spawn getting our stdin */ os_fd_set_cloexec(STDIN_FILENO); + cmdline = copy_command_line(argc, argv); parse_options(core_options, ARRAY_LENGTH(core_options), &argc, argv); if (help) @@ -1614,6 +1637,9 @@ int main(int argc, char *argv[]) logger = weston_log_subscriber_create_log(logfile); weston_log_subscribe(log_ctx, logger, "log"); + weston_log("Command line: %s\n", cmdline); + free(cmdline); + if (load_config(&ivi.config, no_config, config_file) < 0) goto error_signals; section = weston_config_get_section(ivi.config, "core", NULL, NULL);