Document this FreeBSD peculiarity.
PR: 255664
Reported by: des.gaufres@gmail.com
Differential D30188
[patch] syslog.3 - LOG_PID cannot be disabled fernape on May 10 2021, 3:26 PM. Authored by Tags None Referenced Files
Details Document this FreeBSD peculiarity. PR: 255664 We say it in the code (lib/libc/gen/syslog.c): ... (void)fprintf(fp, "%s ", LogTag == NULL ? NILVALUE : LogTag); /* * Provide the process ID regardless of whether LOG_PID has been * specified, as it provides valuable information. Many * applications tend not to use this, even though they should. */ ...
Diff Detail
Event TimelineComment Actions Here is a small repro: #include <stdio.h> #include <syslog.h> #include <unistd.h> int main(int argc, char **argv) { printf("I am process %d\n", getpid()); openlog("myprefix", LOG_PID, LOG_USER); syslog(LOG_WARNING, "hello world with pid"); closelog(); openlog("myotherprefix", 0, LOG_USER); syslog(LOG_WARNING, "hello world without pid"); closelog(); return (0); } $ clang -Wall main.c && ./a.out && grep "hello world" /var/log/messages I am process 10010 May 11 17:06:37 beastie myprefix[10010]: hello world with pid May 11 17:06:37 beastie myotherprefix[10010]: hello world without pid In syslog.h #define LOG_PID 0x01 /* log the pid with each message */ I will not commit anything yet :-) Comment Actions The comment is correct. LOG_PID has no effect and the process ID is always included. This change was made along with the move from RFC 3164 to RFC 5424 log messages. Comment Actions Note that logger(1) manpage is also incorrect now, as it mentions -i switch used to get the PID to be logged with each line, but now is no-op. |