From 0176d059e4b3d020bbd6c7af7ecce6c1cede39a3 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 17 Jun 2026 09:57:50 +0300 Subject: [PATCH v13 6/9] Rename postmaster/interrupt.c to ipc/signal_handlers.c postmaster/interrupt.c contains signal handling functions, so rename it to ipc/signal_handlers.c, to better reflect its contents. The "interrupt" term is now used to mean the concept around CHECK_FOR_INTERRUPTS(). Interrupts can be raised by signal handlers, but it's not the same thing. --- contrib/pg_prewarm/autoprewarm.c | 2 +- contrib/pg_stash_advice/stashpersist.c | 2 +- src/backend/Makefile | 1 + src/backend/commands/copyfrom.c | 1 + src/backend/commands/vacuum.c | 2 +- src/backend/ipc/Makefile | 18 ++++++++++++++++++ src/backend/ipc/meson.build | 5 +++++ .../interrupt.c => ipc/signal_handlers.c} | 8 ++++---- src/backend/meson.build | 1 + src/backend/postmaster/Makefile | 1 - src/backend/postmaster/autovacuum.c | 2 +- src/backend/postmaster/bgwriter.c | 2 +- src/backend/postmaster/checkpointer.c | 2 +- src/backend/postmaster/meson.build | 1 - src/backend/postmaster/pgarch.c | 2 +- src/backend/postmaster/syslogger.c | 2 +- src/backend/postmaster/walsummarizer.c | 2 +- src/backend/postmaster/walwriter.c | 2 +- .../replication/logical/applyparallelworker.c | 2 +- src/backend/replication/logical/launcher.c | 2 +- src/backend/replication/logical/sequencesync.c | 2 +- src/backend/replication/logical/slotsync.c | 2 +- src/backend/replication/logical/worker.c | 2 +- src/backend/replication/slot.c | 2 +- src/backend/replication/walreceiver.c | 2 +- src/backend/replication/walsender.c | 2 +- src/backend/storage/aio/method_worker.c | 2 +- src/backend/tcop/postgres.c | 2 +- src/backend/utils/init/miscinit.c | 2 +- .../interrupt.h => ipc/signal_handlers.h} | 16 ++++++++-------- src/test/modules/worker_spi/worker_spi.c | 2 +- 31 files changed, 60 insertions(+), 36 deletions(-) create mode 100644 src/backend/ipc/Makefile create mode 100644 src/backend/ipc/meson.build rename src/backend/{postmaster/interrupt.c => ipc/signal_handlers.c} (96%) rename src/include/{postmaster/interrupt.h => ipc/signal_handlers.h} (68%) diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c index ba0bc8e6d4a..f11745f4755 100644 --- a/contrib/pg_prewarm/autoprewarm.c +++ b/contrib/pg_prewarm/autoprewarm.c @@ -30,9 +30,9 @@ #include "access/relation.h" #include "access/xact.h" +#include "ipc/signal_handlers.h" #include "pgstat.h" #include "postmaster/bgworker.h" -#include "postmaster/interrupt.h" #include "storage/buf_internals.h" #include "storage/dsm.h" #include "storage/dsm_registry.h" diff --git a/contrib/pg_stash_advice/stashpersist.c b/contrib/pg_stash_advice/stashpersist.c index 5bdf4bddaae..9e08300c541 100644 --- a/contrib/pg_stash_advice/stashpersist.c +++ b/contrib/pg_stash_advice/stashpersist.c @@ -14,10 +14,10 @@ #include #include "common/hashfn.h" +#include "ipc/signal_handlers.h" #include "miscadmin.h" #include "pg_stash_advice.h" #include "postmaster/bgworker.h" -#include "postmaster/interrupt.h" #include "storage/fd.h" #include "storage/ipc.h" #include "storage/latch.h" diff --git a/src/backend/Makefile b/src/backend/Makefile index 162d3f1f2a9..82156eff3c2 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -26,6 +26,7 @@ SUBDIRS = \ commands \ executor \ foreign \ + ipc \ lib \ libpq \ main \ diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c index e6ba012e7d6..86e48df6536 100644 --- a/src/backend/commands/copyfrom.c +++ b/src/backend/commands/copyfrom.c @@ -21,6 +21,7 @@ #include "postgres.h" #include +#include #include #include diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 21e74184b61..5cada287d79 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -43,11 +43,11 @@ #include "commands/repack.h" #include "commands/vacuum.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "nodes/makefuncs.h" #include "pgstat.h" #include "postmaster/autovacuum.h" #include "postmaster/bgworker_internals.h" -#include "postmaster/interrupt.h" #include "storage/bufmgr.h" #include "storage/lmgr.h" #include "storage/pmsignal.h" diff --git a/src/backend/ipc/Makefile b/src/backend/ipc/Makefile new file mode 100644 index 00000000000..4120909ebbe --- /dev/null +++ b/src/backend/ipc/Makefile @@ -0,0 +1,18 @@ +#------------------------------------------------------------------------- +# +# Makefile-- +# Makefile for backend/ipc +# +# IDENTIFICATION +# src/backend/ipc/Makefile +# +#------------------------------------------------------------------------- + +subdir = src/backend/ipc +top_builddir = ../../.. +include $(top_builddir)/src/Makefile.global + +OBJS = \ + signal_handlers.o + +include $(top_srcdir)/src/backend/common.mk diff --git a/src/backend/ipc/meson.build b/src/backend/ipc/meson.build new file mode 100644 index 00000000000..af7dae10b60 --- /dev/null +++ b/src/backend/ipc/meson.build @@ -0,0 +1,5 @@ +# Copyright (c) 2026, PostgreSQL Global Development Group + +backend_sources += files( + 'signal_handlers.c', +) diff --git a/src/backend/postmaster/interrupt.c b/src/backend/ipc/signal_handlers.c similarity index 96% rename from src/backend/postmaster/interrupt.c rename to src/backend/ipc/signal_handlers.c index 20f7e34e204..44b39bc9ecf 100644 --- a/src/backend/postmaster/interrupt.c +++ b/src/backend/ipc/signal_handlers.c @@ -1,13 +1,13 @@ /*------------------------------------------------------------------------- * - * interrupt.c - * Interrupt handling routines. + * signal_handlers.c + * Standard signal handlers. * * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * src/backend/postmaster/interrupt.c + * src/backend/ipc/signal_handlers.c * *------------------------------------------------------------------------- */ @@ -17,8 +17,8 @@ #include #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "miscadmin.h" -#include "postmaster/interrupt.h" #include "storage/ipc.h" #include "storage/latch.h" #include "storage/procsignal.h" diff --git a/src/backend/meson.build b/src/backend/meson.build index f737d799c61..b6af11a2125 100644 --- a/src/backend/meson.build +++ b/src/backend/meson.build @@ -15,6 +15,7 @@ subdir('catalog') subdir('commands') subdir('executor') subdir('foreign') +subdir('ipc') subdir('jit') subdir('lib') subdir('libpq') diff --git a/src/backend/postmaster/Makefile b/src/backend/postmaster/Makefile index 55044b2bc6f..a478ddbab2e 100644 --- a/src/backend/postmaster/Makefile +++ b/src/backend/postmaster/Makefile @@ -20,7 +20,6 @@ OBJS = \ checkpointer.o \ datachecksum_state.o \ fork_process.o \ - interrupt.o \ launch_backend.o \ pgarch.o \ pmchild.o \ diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 31cad5df015..33d9a8ddcdf 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -81,13 +81,13 @@ #include "commands/vacuum.h" #include "common/int.h" #include "funcapi.h" +#include "ipc/signal_handlers.h" #include "lib/ilist.h" #include "libpq/pqsignal.h" #include "miscadmin.h" #include "nodes/makefuncs.h" #include "pgstat.h" #include "postmaster/autovacuum.h" -#include "postmaster/interrupt.h" #include "postmaster/postmaster.h" #include "storage/aio_subsys.h" #include "storage/bufmgr.h" diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index 6b7312b75d9..f199d92f57c 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -33,11 +33,11 @@ #include "access/xlog.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "libpq/pqsignal.h" #include "pgstat.h" #include "postmaster/auxprocess.h" #include "postmaster/bgwriter.h" -#include "postmaster/interrupt.h" #include "storage/aio_subsys.h" #include "storage/buf_internals.h" #include "storage/bufmgr.h" diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c index bd73888747b..0be0b9009e8 100644 --- a/src/backend/postmaster/checkpointer.c +++ b/src/backend/postmaster/checkpointer.c @@ -45,12 +45,12 @@ #include "catalog/pg_authid.h" #include "commands/defrem.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "libpq/pqsignal.h" #include "pgstat.h" #include "port/atomics.h" #include "postmaster/auxprocess.h" #include "postmaster/bgwriter.h" -#include "postmaster/interrupt.h" #include "replication/syncrep.h" #include "storage/aio_subsys.h" #include "storage/bufmgr.h" diff --git a/src/backend/postmaster/meson.build b/src/backend/postmaster/meson.build index 6cba23bbeef..c8baef330f6 100644 --- a/src/backend/postmaster/meson.build +++ b/src/backend/postmaster/meson.build @@ -8,7 +8,6 @@ backend_sources += files( 'checkpointer.c', 'datachecksum_state.c', 'fork_process.c', - 'interrupt.c', 'launch_backend.c', 'pgarch.c', 'pmchild.c', diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 8098e29ff65..f9db35c9285 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -34,11 +34,11 @@ #include "archive/archive_module.h" #include "archive/shell_archive.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "lib/binaryheap.h" #include "libpq/pqsignal.h" #include "pgstat.h" #include "postmaster/auxprocess.h" -#include "postmaster/interrupt.h" #include "postmaster/pgarch.h" #include "storage/condition_variable.h" #include "storage/aio_subsys.h" diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c index b399adcce75..64d7511ee5e 100644 --- a/src/backend/postmaster/syslogger.c +++ b/src/backend/postmaster/syslogger.c @@ -32,6 +32,7 @@ #include #include "common/file_perm.h" +#include "ipc/signal_handlers.h" #include "lib/stringinfo.h" #include "libpq/pqsignal.h" #include "miscadmin.h" @@ -39,7 +40,6 @@ #include "pgstat.h" #include "pgtime.h" #include "port/pg_bitutils.h" -#include "postmaster/interrupt.h" #include "postmaster/postmaster.h" #include "postmaster/syslogger.h" #include "storage/dsm.h" diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c index ea6afab8d69..ed080cdac49 100644 --- a/src/backend/postmaster/walsummarizer.c +++ b/src/backend/postmaster/walsummarizer.c @@ -33,10 +33,10 @@ #include "commands/dbcommands_xlog.h" #include "common/blkreftable.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "libpq/pqsignal.h" #include "pgstat.h" #include "postmaster/auxprocess.h" -#include "postmaster/interrupt.h" #include "postmaster/walsummarizer.h" #include "replication/walreceiver.h" #include "storage/aio_subsys.h" diff --git a/src/backend/postmaster/walwriter.c b/src/backend/postmaster/walwriter.c index d32297fc259..25745ed30b3 100644 --- a/src/backend/postmaster/walwriter.c +++ b/src/backend/postmaster/walwriter.c @@ -47,9 +47,9 @@ #include "access/xlog.h" #include "libpq/pqsignal.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "pgstat.h" #include "postmaster/auxprocess.h" -#include "postmaster/interrupt.h" #include "postmaster/walwriter.h" #include "storage/aio_subsys.h" #include "storage/bufmgr.h" diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c index 6e5f3ab123f..adf7766e8c7 100644 --- a/src/backend/replication/logical/applyparallelworker.c +++ b/src/backend/replication/logical/applyparallelworker.c @@ -158,10 +158,10 @@ #include "postgres.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "libpq/pqformat.h" #include "libpq/pqmq.h" #include "pgstat.h" -#include "postmaster/interrupt.h" #include "replication/logicallauncher.h" #include "replication/logicalworker.h" #include "replication/origin.h" diff --git a/src/backend/replication/logical/launcher.c b/src/backend/replication/logical/launcher.c index 920c5a3de99..962238b8202 100644 --- a/src/backend/replication/logical/launcher.c +++ b/src/backend/replication/logical/launcher.c @@ -27,9 +27,9 @@ #include "funcapi.h" #include "ipc/interrupt.h" #include "lib/dshash.h" +#include "ipc/signal_handlers.h" #include "pgstat.h" #include "postmaster/bgworker.h" -#include "postmaster/interrupt.h" #include "replication/logicallauncher.h" #include "replication/origin.h" #include "replication/slot.h" diff --git a/src/backend/replication/logical/sequencesync.c b/src/backend/replication/logical/sequencesync.c index 1cfd9a36b34..b722288ae39 100644 --- a/src/backend/replication/logical/sequencesync.c +++ b/src/backend/replication/logical/sequencesync.c @@ -57,8 +57,8 @@ #include "catalog/pg_subscription_rel.h" #include "commands/sequence.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "pgstat.h" -#include "postmaster/interrupt.h" #include "replication/logicalworker.h" #include "replication/worker_internal.h" #include "storage/lwlock.h" diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c index 489c115f45f..96592ce4514 100644 --- a/src/backend/replication/logical/slotsync.c +++ b/src/backend/replication/logical/slotsync.c @@ -64,9 +64,9 @@ #include "access/xlogrecovery.h" #include "catalog/pg_database.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "libpq/pqsignal.h" #include "pgstat.h" -#include "postmaster/interrupt.h" #include "replication/logical.h" #include "replication/slotsync.h" #include "replication/snapbuild.h" diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 7799266c614..7219b80c0d4 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -263,6 +263,7 @@ #include "commands/trigger.h" #include "executor/executor.h" #include "executor/execPartition.h" +#include "ipc/signal_handlers.h" #include "libpq/pqformat.h" #include "miscadmin.h" #include "optimizer/optimizer.h" @@ -270,7 +271,6 @@ #include "pgstat.h" #include "port/pg_bitutils.h" #include "postmaster/bgworker.h" -#include "postmaster/interrupt.h" #include "postmaster/walwriter.h" #include "replication/conflict.h" #include "replication/logicallauncher.h" diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index 010657fb400..8c61583fbfd 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -45,8 +45,8 @@ #include "common/file_utils.h" #include "common/string.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "pgstat.h" -#include "postmaster/interrupt.h" #include "replication/logicallauncher.h" #include "replication/slotsync.h" #include "replication/slot.h" diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index d7804a73454..9abc9817362 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -61,11 +61,11 @@ #include "catalog/pg_authid.h" #include "funcapi.h" #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "libpq/pqformat.h" #include "libpq/pqsignal.h" #include "pgstat.h" #include "postmaster/auxprocess.h" -#include "postmaster/interrupt.h" #include "replication/walreceiver.h" #include "replication/walsender.h" #include "storage/ipc.h" diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 795393b0be0..e5ac08eb179 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -65,13 +65,13 @@ #include "catalog/pg_type.h" #include "commands/defrem.h" #include "funcapi.h" +#include "ipc/signal_handlers.h" #include "libpq/libpq.h" #include "libpq/pqformat.h" #include "libpq/protocol.h" #include "miscadmin.h" #include "nodes/replnodes.h" #include "pgstat.h" -#include "postmaster/interrupt.h" #include "replication/decode.h" #include "replication/logical.h" #include "replication/slotsync.h" diff --git a/src/backend/storage/aio/method_worker.c b/src/backend/storage/aio/method_worker.c index abffeefc2c1..76635e3c41c 100644 --- a/src/backend/storage/aio/method_worker.c +++ b/src/backend/storage/aio/method_worker.c @@ -31,10 +31,10 @@ #include #include "ipc/interrupt.h" +#include "ipc/signal_handlers.h" #include "libpq/pqsignal.h" #include "port/pg_bitutils.h" #include "postmaster/auxprocess.h" -#include "postmaster/interrupt.h" #include "storage/aio.h" #include "storage/aio_internal.h" #include "storage/aio_subsys.h" diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 80449b0b3cd..1c926928e9c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -41,6 +41,7 @@ #include "commands/prepare.h" #include "commands/repack.h" #include "common/pg_prng.h" +#include "ipc/signal_handlers.h" #include "jit/jit.h" #include "libpq/libpq.h" #include "libpq/pqformat.h" @@ -55,7 +56,6 @@ #include "pg_trace.h" #include "pgstat.h" #include "port/pg_getopt_ctx.h" -#include "postmaster/interrupt.h" #include "postmaster/postmaster.h" #include "replication/logicallauncher.h" #include "replication/logicalworker.h" diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 5343d4219ae..f4992ff1622 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -32,13 +32,13 @@ #include "access/parallel.h" #include "catalog/pg_authid.h" #include "common/file_perm.h" +#include "ipc/signal_handlers.h" #include "libpq/libpq.h" #include "libpq/pqsignal.h" #include "mb/pg_wchar.h" #include "miscadmin.h" #include "pgstat.h" #include "postmaster/autovacuum.h" -#include "postmaster/interrupt.h" #include "postmaster/postmaster.h" #include "replication/slotsync.h" #include "storage/fd.h" diff --git a/src/include/postmaster/interrupt.h b/src/include/ipc/signal_handlers.h similarity index 68% rename from src/include/postmaster/interrupt.h rename to src/include/ipc/signal_handlers.h index e1482626dfd..a499a271538 100644 --- a/src/include/postmaster/interrupt.h +++ b/src/include/ipc/signal_handlers.h @@ -1,23 +1,23 @@ /*------------------------------------------------------------------------- * - * interrupt.h - * Interrupt handling routines. + * signal_handlers.h + * Standard signal handling routines. * - * Responses to interrupts are fairly varied and many types of backends - * have their own implementations, but we provide a few generic things - * here to facilitate code reuse. + * Responses to signals are fairly varied and many types of backends have + * their own implementations, but we provide a few generic things here to + * facilitate code reuse. * * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * src/include/postmaster/interrupt.h + * src/include/ipc/signal_handlers.h * *------------------------------------------------------------------------- */ -#ifndef INTERRUPT_H -#define INTERRUPT_H +#ifndef SIGNAL_HANDLERS_H +#define SIGNAL_HANDLERS_H #include diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c index b635a486349..bd9002bf41d 100644 --- a/src/test/modules/worker_spi/worker_spi.c +++ b/src/test/modules/worker_spi/worker_spi.c @@ -23,9 +23,9 @@ #include "postgres.h" /* These are always necessary for a bgworker */ +#include "ipc/signal_handlers.h" #include "miscadmin.h" #include "postmaster/bgworker.h" -#include "postmaster/interrupt.h" #include "storage/latch.h" /* these headers are used by this particular worker's code */ -- 2.47.3