From 6bc8525a8d47d49907650b65d4231ee61893fb2d Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Mon, 1 Aug 2022 13:17:01 +0200 Subject: [PATCH] Ensure both logger and syslogd output the same version string Slight differences in output when called with `-v` flag: - Should output to stdout, that's what people expect (not an error) - Should output *project* name and version, for syslogd this is not so obvious since it *logs* 'syslogd vx.y.z' while the version is 'sysklogd vx.y.z' Signed-off-by: Joachim Wiberg --- src/logger.c | 2 +- src/syslogd.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/logger.c b/src/logger.c index 6bfb171..8ec70ca 100644 --- a/src/logger.c +++ b/src/logger.c @@ -366,7 +366,7 @@ int main(int argc, char *argv[]) break; case 'v': /* version */ - fprintf(stderr, "%s\n", version_info); + printf("%s\n", version_info); return 0; default: diff --git a/src/syslogd.c b/src/syslogd.c index c9aaa2b..81cbee5 100644 --- a/src/syslogd.c +++ b/src/syslogd.c @@ -107,6 +107,8 @@ static volatile sig_atomic_t debugging_on; static volatile sig_atomic_t restart; static volatile sig_atomic_t rotate_signal; +static const char version_info[] = PACKAGE_NAME " v" PACKAGE_VERSION; + /* * Intervals at which we flush out "message repeated" messages, * in seconds after previous message is logged. After each flush, @@ -494,8 +496,8 @@ int main(int argc, char *argv[]) break; case 'v': - printf("syslogd v%s\n", VERSION); - exit(0); + printf("%s\n", version_info); + return 0; case '?': return usage(0);