From 3ad0728c817bf8abd2c76bd11d856967509b307c Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 21 Nov 2006 20:59:53 +0000 Subject: On systems that have setsid(2) (which should be just about everything except Windows), arrange for each postmaster child process to be its own process group leader, and deliver signals SIGINT, SIGTERM, SIGQUIT to the whole process group not only the direct child process. This provides saner behavior for archive and recovery scripts; in particular, it's possible to shut down a warm-standby recovery server using "pg_ctl stop -m immediate", since delivery of SIGQUIT to the startup subprocess will result in killing the waiting recovery_command. Also, this makes Query Cancel and statement_timeout apply to scripts being run from backends via system(). (There is no support in the core backend for that, but it's widely done using untrusted PLs.) Per gripe from Stephen Harris and subsequent discussion. --- src/backend/utils/adt/misc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/backend/utils/adt/misc.c') diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 014d2c8bf6d..14f89e7d2e5 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.54 2006/10/04 00:29:59 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.55 2006/11/21 20:59:53 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,12 @@ pg_signal_backend(int pid, int sig) return false; } + /* If we have setsid(), signal the backend's whole process group */ +#ifdef HAVE_SETSID + if (kill(-pid, sig)) +#else if (kill(pid, sig)) +#endif { /* Again, just a warning to allow loops */ ereport(WARNING, -- cgit v1.2.3