The -i flag in the util-linux, and upstream sysklogd, projects add
PID to syslog messages, using the LOG_PID flag.

Signed-off-by: Joachim Wiberg <troglo...@gmail.com>
---
 sysklogd/logger.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sysklogd/logger.c b/sysklogd/logger.c
index 04b2c8e3b..8424ae206 100644
--- a/sysklogd/logger.c
+++ b/sysklogd/logger.c
@@ -21,9 +21,10 @@
 //kbuild:lib-$(CONFIG_LOGGER) += syslogd_and_logger.o
 
 //usage:#define logger_trivial_usage
-//usage:       "[-s] [-t TAG] [-p PRIO] [MESSAGE]"
+//usage:       "[-i] [-s] [-t TAG] [-p PRIO] [MESSAGE]"
 //usage:#define logger_full_usage "\n\n"
 //usage:       "Write MESSAGE (or stdin) to syslog\n"
+//usage:     "\n       -i      Log PID of logger to system log"
 //usage:     "\n       -s      Log to stderr as well as the system log"
 //usage:     "\n       -t TAG  Log using the specified tag (defaults to user 
name)"
 //usage:     "\n       -p PRIO Priority (number or FACILITY.LEVEL pair)"
@@ -105,10 +106,12 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
        str_t = uid2uname_utoa(geteuid());
 
        /* Parse any options */
-       opt = getopt32(argv, "p:st:", &str_p, &str_t);
+       opt = getopt32(argv, "p:st:i", &str_p, &str_t);
 
        if (opt & 0x2) /* -s */
                i |= LOG_PERROR;
+       if (opt & 0x8) /* -i */
+               i |= LOG_PID;
        //if (opt & 0x4) /* -t */
        openlog(str_t, i, 0);
        i = LOG_USER | LOG_NOTICE;
-- 
2.34.1

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to