git: 2ce3ef550350 - main - syslog: fix PID of forking process

From: Eugene Grosbein <eugen_at_FreeBSD.org>
Date: Tue, 03 Jan 2023 08:58:51 UTC
The branch main has been updated by eugen:

URL: https://cgit.FreeBSD.org/src/commit/?id=2ce3ef55035093cac7839e71e9ff91f5562ebc29

commit 2ce3ef55035093cac7839e71e9ff91f5562ebc29
Author:     Eugene Grosbein <eugen@FreeBSD.org>
AuthorDate: 2023-01-03 08:53:47 +0000
Commit:     Eugene Grosbein <eugen@FreeBSD.org>
CommitDate: 2023-01-03 08:58:36 +0000

    syslog: fix PID of forking process
    
    Do not cache PID for a process that does not fabricate it,
    calls openlog() before forking and does not call exec() thereafter.
    
    PR:             268666
    Fixes:          e9ae9fa93745669b7dd0341d333257ad6cfe8e37
    Tested by:      kp
    MFC after:      3 days
---
 lib/libc/gen/syslog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index 2424cef78dd7..08bdfdbeb1e7 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -218,7 +218,7 @@ vsyslog1(int pri, const char *fmt, va_list ap)
 	 * specified, as it provides valuable information. Many
 	 * applications tend not to use this, even though they should.
 	 */
-	if (LogPid == -1)
+	if (LogTagLength <= 0)
 		LogPid = getpid();
 	(void)fprintf(fp, "%d ", (int)LogPid);
 	/* Message ID. */