Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8fd0498

Browse files
Remove obsolete check in SIGTERM handler for the startup process.
Thanks to commit 3b00fdb, this check in the SIGTERM handler for the startup process is now obsolete and can be removed. Instead of leaving around the dead function write_stderr_signal_safe(), I've opted to just remove it for now. This partially reverts commit 97550c0. Reviewed-by: Andres Freund, Noah Misch Discussion: https://postgr.es/m/20231121212008.GA3742740%40nathanxps13
1 parent 28e4632 commit 8fd0498

File tree

3 files changed

+1
-50
lines changed

3 files changed

+1
-50
lines changed

src/backend/postmaster/startup.c

+1-16
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
*/
2020
#include "postgres.h"
2121

22-
#include <unistd.h>
23-
2422
#include "access/xlog.h"
2523
#include "access/xlogrecovery.h"
2624
#include "access/xlogutils.h"
@@ -112,20 +110,7 @@ static void
112110
StartupProcShutdownHandler(SIGNAL_ARGS)
113111
{
114112
if (in_restore_command)
115-
{
116-
/*
117-
* If we are in a child process (e.g., forked by system() in
118-
* RestoreArchivedFile()), we don't want to call any exit callbacks.
119-
* The parent will take care of that.
120-
*/
121-
if (MyProcPid == (int) getpid())
122-
proc_exit(1);
123-
else
124-
{
125-
write_stderr_signal_safe("StartupProcShutdownHandler() called in child process\n");
126-
_exit(1);
127-
}
128-
}
113+
proc_exit(1);
129114
else
130115
shutdown_requested = true;
131116
WakeupRecovery();

src/backend/utils/error/elog.c

-28
Original file line numberDiff line numberDiff line change
@@ -3737,31 +3737,3 @@ write_stderr(const char *fmt,...)
37373737
#endif
37383738
va_end(ap);
37393739
}
3740-
3741-
3742-
/*
3743-
* Write a message to STDERR using only async-signal-safe functions. This can
3744-
* be used to safely emit a message from a signal handler.
3745-
*
3746-
* TODO: It is likely possible to safely do a limited amount of string
3747-
* interpolation (e.g., %s and %d), but that is not presently supported.
3748-
*/
3749-
void
3750-
write_stderr_signal_safe(const char *str)
3751-
{
3752-
int nwritten = 0;
3753-
int ntotal = strlen(str);
3754-
3755-
while (nwritten < ntotal)
3756-
{
3757-
int rc;
3758-
3759-
rc = write(STDERR_FILENO, str + nwritten, ntotal - nwritten);
3760-
3761-
/* Just give up on error. There isn't much else we can do. */
3762-
if (rc == -1)
3763-
return;
3764-
3765-
nwritten += rc;
3766-
}
3767-
}

src/include/utils/elog.h

-6
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,4 @@ extern void write_jsonlog(ErrorData *edata);
536536
*/
537537
extern void write_stderr(const char *fmt,...) pg_attribute_printf(1, 2);
538538

539-
/*
540-
* Write a message to STDERR using only async-signal-safe functions. This can
541-
* be used to safely emit a message from a signal handler.
542-
*/
543-
extern void write_stderr_signal_safe(const char *fmt);
544-
545539
#endif /* ELOG_H */

0 commit comments

Comments
 (0)