pgkill for windows

Started by Andrew Dunstanabout 22 years ago8 messagespatches
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

Attached are 2 files needed to create a pgkill facility for Windows, and
a complementary patch for src/bin/Makefile

It is adapted from the facility on the Win32 page, but uses the builtin
signal definitions rather than using its own.

This facility is needed for shutting down postgres cleanly as part of
'make check', as we don't really use signals in Windows, we only emulate
them using our own scheme, so any native kill program doesn't have the
desired effect.

cheers

andrew

Attachments:

Makefiletext/plain; name=MakefileDownload
pgkill-make-patchtext/plain; name=pgkill-make-patchDownload+4-0
pgkill.ctext/x-c; name=pgkill.cDownload
#2Peter Eisentraut
peter_e@gmx.net
In reply to: Andrew Dunstan (#1)
Re: pgkill for windows

Andrew Dunstan wrote:

Attached are 2 files needed to create a pgkill facility for Windows,
and a complementary patch for src/bin/Makefile

If it's only for the regression tests, then it should go into that
directory.

#3Magnus Hagander
magnus@hagander.net
In reply to: Peter Eisentraut (#2)
Re: pgkill for windows

Andrew Dunstan wrote:

Attached are 2 files needed to create a pgkill facility for

Windows,

and a complementary patch for src/bin/Makefile

If it's only for the regression tests, then it should go into
that directory.

It is not. It is a tool required to do any "controlled backend
termination" on win32. The regression tests is just one user of it.
Regression tests is just one user of it.

(You can shutdown the postmaster using Ctrl-C or using the Service
Control Manager, but pgkill is required for individual backend
signalling).

//Magnus

#4Andrew Dunstan
andrew@dunslane.net
In reply to: Peter Eisentraut (#2)
Re: pgkill for windows

Peter Eisentraut wrote:

Andrew Dunstan wrote:

Attached are 2 files needed to create a pgkill facility for Windows,
and a complementary patch for src/bin/Makefile

If it's only for the regression tests, then it should go into that
directory.

In effect you need this on Windows anywhere that in Unix you would want
to use kill (1) on a postgres process.

cheers

andrew

#5Bruce Momjian
bruce@momjian.us
In reply to: Andrew Dunstan (#4)
Re: pgkill for windows

Andrew Dunstan wrote:

Attached are 2 files needed to create a pgkill facility for Windows,
and a complementary patch for src/bin/Makefile

If it's only for the regression tests, then it should go into that
directory.

In effect you need this on Windows anywhere that in Unix you would want
to use kill (1) on a postgres process.

Is this something that should be part of the Win32 pg_ctl C code
instead?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#6Magnus Hagander
magnus@hagander.net
In reply to: Bruce Momjian (#5)
Re: pgkill for windows

Attached are 2 files needed to create a pgkill facility

for Windows,

and a complementary patch for src/bin/Makefile

If it's only for the regression tests, then it should go into that
directory.

In effect you need this on Windows anywhere that in Unix you would
want to use kill (1) on a postgres process.

Is this something that should be part of the Win32 pg_ctl C
code instead?

I'd say also, not instead.
pg_ctl still only works on the postmaster.

//Magnus

#7Bruce Momjian
bruce@momjian.us
In reply to: Andrew Dunstan (#1)
Re: pgkill for windows

I was hoping to avoid platform-specific binaries. Once pg_ctl is done
in C, it can start/stop the postmaster, but not individual backends.
Can we add a flag to pg_ctl so it can send arbitrary signals to
processed on Win32? That would be best, I think.

---------------------------------------------------------------------------

Andrew Dunstan wrote:

Attached are 2 files needed to create a pgkill facility for Windows, and
a complementary patch for src/bin/Makefile

It is adapted from the facility on the Win32 page, but uses the builtin
signal definitions rather than using its own.

This facility is needed for shutting down postgres cleanly as part of
'make check', as we don't really use signals in Windows, we only emulate
them using our own scheme, so any native kill program doesn't have the
desired effect.

cheers

andrew

#-------------------------------------------------------------------------
#
# Makefile for src/bin/pgkill
#
# Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql-server/src/bin/pgkill/Makefile,v 1.36 2004/04/26 17:40:48 momjian Exp $
#
#-------------------------------------------------------------------------

subdir = src/bin/pgkill
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global

override CPPFLAGS := -DPGBINDIR=\"$(bindir)\" -DPGDATADIR=\"$(datadir)\" -I$(libpq_srcdir) $(CPPFLAGS)

OBJS= pgkill.o

all: pgkill

pgkill: $(OBJS)
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@$(X)

install: all installdirs
$(INSTALL_PROGRAM) pgkill$(X) $(DESTDIR)$(bindir)/pgkill$(X)

installdirs:
$(mkinstalldirs) $(DESTDIR)$(bindir)

uninstall:
rm -f $(DESTDIR)$(bindir)/pgkill$(X)

clean distclean maintainer-clean:
rm -f pgkill$(X) $(OBJS)

# ensure that changes in bindir etc. propagate into object file
pgkill.o: pgkill.c $(top_builddir)/src/Makefile.global

Index: src/bin/Makefile
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/Makefile,v
retrieving revision 1.43
diff -c -r1.43 Makefile
*** src/bin/Makefile	20 Apr 2004 00:40:06 -0000	1.43
--- src/bin/Makefile	10 May 2004 16:17:52 -0000
***************
*** 15,20 ****
--- 15,24 ----
DIRS := initdb initlocation ipcclean pg_ctl pg_dump \
psql scripts pg_config pg_controldata pg_resetxlog
+ ifeq ($(host_os), mingw32)
+ DIRS := $(DIRS) pgkill
+ endif
+ 

all install installdirs uninstall depend distprep:
@for dir in $(DIRS); do $(MAKE) -C $$dir $@ || exit; done

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#8Andrew Dunstan
andrew@dunslane.net
In reply to: Bruce Momjian (#7)
Re: pgkill for windows

Bruce Momjian said:

I was hoping to avoid platform-specific binaries. Once pg_ctl is done
in C, it can start/stop the postmaster, but not individual backends.
Can we add a flag to pg_ctl so it can send arbitrary signals to
processed on Win32? That would be best, I think.

Ok, that makes sense.

I am working on pg_ctl and hope to have a first cut in a day or two
(everything is done except the startup code).

cheers

andrew