Page MenuHomeFreeBSD

[patch] syslog.3 - LOG_PID cannot be disabled
ClosedPublic

Authored by fernape on May 10 2021, 3:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 9 2024, 7:15 PM
Unknown Object (File)
Dec 20 2023, 2:53 AM
Unknown Object (File)
Dec 12 2023, 5:20 AM
Unknown Object (File)
Nov 26 2023, 10:00 AM
Unknown Object (File)
Nov 21 2023, 7:14 AM
Unknown Object (File)
Nov 21 2023, 4:51 AM
Unknown Object (File)
Nov 11 2023, 2:34 AM
Unknown Object (File)
Nov 8 2023, 11:02 PM
Subscribers

Details

Reviewers
0mp
gbe
imp
jilles
Group Reviewers
manpages
Summary

Document this FreeBSD peculiarity.

PR: 255664
Reported by: des.gaufres@gmail.com

Test Plan

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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 39099
Build 35988: arc lint + arc unit

Event Timeline

gbe added reviewers: imp, jilles.
gbe added a subscriber: jilles.

OK, for the manpage side of things, but I am not sure if this is true, since the code fragment from libc doesn't point out that this option can't be disabled?

@imp @jilles what do you think?

This revision is now accepted and ready to land.May 11 2021, 2:55 PM
In D30188#678418, @gbe wrote:

OK, for the manpage side of things, but I am not sure if this is true, since the code fragment from libc doesn't point out that this option can't be disabled?

@imp @jilles what do you think?

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 :-)

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.

@gbe are we good to go?

Sure, this differential is definitely LGTM.

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.

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.

Thanks for reporting this. I created a new revision