Hi,
> In any case, the proposed patch almost certainly introduces new
> problems, in that you dropped the fcloses's into code that
> executes repeatedly.
I guess it's better to place fclose() right after successful syslogger start.
In that case we close descriptors just one time. But it's enough to solve the
problem.
Developers who debug syslogger generally should see problems before we close
descriptors.
In other case they can edit code of syslogger.
There is another way to solve this problem:
We can give users the opportunity to leave or close descriptors.
I.e. config switch for this. But I think that it's too complicated.
One can reproduce the problem by following steps in previous messages.
_________
Regards, Sviatoslav Ermilin
From 809121ee5494d9189a757cbc924c0c933fd64e14 Mon Sep 17 00:00:00 2001
From: Ermilin Sviatoslav <ermili...@yandex.ru>
Date: Wed, 2 Oct 2019 11:59:00 +0500
Subject: [PATCH] Close stderr and stdout in syslogger.
Debian tools from postgresql-common starts pg_ctl piped to logfile.
Descriptor is piped to logfile and block it for delete.
That is why we can't delete logfile.1 after logrotate.
And after second logrotate logfile.1 is in "deleted" status,
but can't be deleted in fact.
---
src/backend/postmaster/syslogger.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index 14d72d38d7..aa063cd08d 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -296,6 +296,8 @@ SysLoggerMain(int argc, char *argv[])
*/
whereToSendOutput = DestNone;
+ fclose(stderr);
+ fclose(stdout);
/* main worker loop */
for (;;)
{
--
2.20.1 (Apple Git-117)