aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2024-02-14 16:34:18 -0600
committerNathan Bossart <nathan@postgresql.org>2024-02-14 16:34:18 -0600
commit28e46325091dfac5c6ab9ea1e047a8d09dbd16e7 (patch)
treef48457af83f13b8bba8d600fe33aef1d39373e26 /doc/src
parent3b00fdba9f20b641d5d3c2b781cd435b23540e61 (diff)
downloadpostgresql-28e46325091dfac5c6ab9ea1e047a8d09dbd16e7.tar.gz
postgresql-28e46325091dfac5c6ab9ea1e047a8d09dbd16e7.zip
Centralize logic for restoring errno in signal handlers.
Presently, we rely on each individual signal handler to save the initial value of errno and then restore it before returning if needed. This is easily forgotten and, if missed, often goes undetected for a long time. In commit 3b00fdba9f, we introduced a wrapper signal handler function that checks whether MyProcPid matches getpid(). This commit moves the aforementioned errno restoration code from the individual signal handlers to the new wrapper handler so that we no longer need to worry about missing it. Reviewed-by: Andres Freund, Noah Misch Discussion: https://postgr.es/m/20231121212008.GA3742740%40nathanxps13
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/sources.sgml8
1 files changed, 0 insertions, 8 deletions
diff --git a/doc/src/sgml/sources.sgml b/doc/src/sgml/sources.sgml
index 5d1d510f8e7..0dae4d9158f 100644
--- a/doc/src/sgml/sources.sgml
+++ b/doc/src/sgml/sources.sgml
@@ -1007,18 +1007,10 @@ MemoryContextSwitchTo(MemoryContext context)
static void
handle_sighup(SIGNAL_ARGS)
{
- int save_errno = errno;
-
got_SIGHUP = true;
SetLatch(MyLatch);
-
- errno = save_errno;
}
</programlisting>
- <varname>errno</varname> is saved and restored because
- <function>SetLatch()</function> might change it. If that were not done
- interrupted code that's currently inspecting <varname>errno</varname> might see the wrong
- value.
</para>
</simplesect>