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:		e9ae9fa937
Tested by:	kp
MFC after:	3 days
This commit is contained in:
Eugene Grosbein 2023-01-03 15:53:47 +07:00
parent 17f2b12a38
commit 2ce3ef5503

View File

@ -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. */