X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=df55dc9fb65880db9dc75373c390634849e0fd34;hp=d71d92446ce71e14177e26005797211c4f7f0730;hb=4ba92f185fb1d0b112cbc804a261939f5f81dc34;hpb=83cea427013b03a98811e88964f60b1f27bc4345 diff --git a/src/common/utils.c b/src/common/utils.c index d71d92446..df55dc9fb 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -1341,7 +1341,40 @@ int utils_truncate_stream_file(int fd, off_t length) PERROR("lseek"); goto end; } - end: return ret; } + +static const char *get_man_bin_path(void) +{ + char *env_man_path = getenv(DEFAULT_MAN_BIN_PATH_ENV); + + if (env_man_path) { + return env_man_path; + } + + return DEFAULT_MAN_BIN_PATH; +} + +LTTNG_HIDDEN +int utils_show_man_page(int section, const char *page_name) +{ + char section_string[8]; + const char *man_bin_path = get_man_bin_path(); + int ret; + + /* Section integer -> section string */ + ret = sprintf(section_string, "%d", section); + assert(ret > 0 && ret < 8); + + /* + * Execute man pager. + * + * We provide --manpath to man here because LTTng-tools can + * be installed outside /usr, in which case its man pages are + * not located in the default /usr/share/man directory. + */ + ret = execlp(man_bin_path, "man", "--manpath", MANPATH, + section_string, page_name, NULL); + return ret; +}