X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;h=16d2f817ad8a1b21d99228a67e5bba25e0d1f3fa;hb=f0b03c2289d0f84c1e2dc41be70cd0bcc222e181;hp=d71d92446ce71e14177e26005797211c4f7f0730;hpb=93ec662e687dc15a3601704a1e0c96c51ad228c9;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index d71d92446..16d2f817a 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -189,6 +189,10 @@ char *utils_partial_realpath(const char *path, char *resolved_path, size_t size) error: free(resolved_path); free(cut_path); + free(try_path); + if (try_path_prev != try_path) { + free(try_path_prev); + } return NULL; } @@ -850,6 +854,7 @@ int utils_rotate_stream_file(char *path_name, char *file_name, uint64_t size, PERROR("Closing tracefile"); goto error; } + *stream_fd = -1; if (count > 0) { /* @@ -1341,7 +1346,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 = lttng_secure_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 -M 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", "-M", MANPATH, + section_string, page_name, NULL); + return ret; +}