[PATCHES] pgkill for windows

2004-05-10 Thread Andrew Dunstan


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 [EMAIL PROTECTED](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/Makefile20 Apr 2004 00:40:06 -  1.43
--- src/bin/Makefile10 May 2004 16:17:52 -
***
*** 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
#include stdio.h
#include stdlib.h
#define WIN32_LEAN_AND_MEAN
#include windows.h
#include signal.h
#include pqsignal.h

static void Usage(void) {
  printf(Usage: pgkill signal pid\n);
  printf(Signal must be uppercase..\n);
  exit(1);
}

static int
pgkill(int pid, int sig)
{
charpipename[128];
BYTEsigData = sig;
BYTEsigRet = 0;
DWORD   bytes;

wsprintf(pipename, .\\pipe\\pgsignal_%i, pid);
if (!CallNamedPipe(pipename, sigData, 1, sigRet, 1, bytes, 1000))
{
  printf(Failed in call: %ld\n,GetLastError());
return -1;
}
if (bytes != 1 || sigRet != sig)
{
  printf(Invalid return value!\n);
return -1;
}

return 0;
}

int main(int argc, char *argv[]) {
  int sig = -1;
  int pid = 0;

  if (argc != 3) 
Usage();
  
  if (!strcmp(argv[1],HUP))
sig = SIGHUP;
  else if (!strcmp(argv[1],INT))
sig = SIGINT;
  else if (!strcmp(argv[1],QUIT))
sig = SIGQUIT;
  else if (!strcmp(argv[1],ABRT))
sig = SIGABRT;
  else if (!strcmp(argv[1],KILL))
sig = SIGKILL;
  else if (!strcmp(argv[1],TERM))
sig = SIGTERM;
  else if (!strcmp(argv[1],USR1))
sig = SIGUSR1;
  else if (!strcmp(argv[1],USR2))
sig = SIGUSR2;

  if (sig == -1)
Usage();


  pid = atoi(argv[2]);
  if (pid == 0)
Usage();

  printf(Got: %i\n,pgkill(pid,sig));
  exit(0);
}

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


Re: [PATCHES] patch for different join result order on regression test for win32

2004-05-10 Thread Tom Lane
Andrew Dunstan [EMAIL PROTECTED] writes:
 This resultmap patch and regression test result file allow the join 
 regression test to succeed under Mingw.

This is the hard way to do it.  Instead of using the resultmap
mechanism, pretend the difference is a locale difference, and
just add the file as join_1.out (I think that's the right naming
convention, but check it).  I don't think we really need to tie this
to a specific OS, which is what the resultmap mechanism is intended
to do.  IIRC people have gotten similar differences on other OSes.

regards, tom lane

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

   http://www.postgresql.org/docs/faqs/FAQ.html


Re: [PATCHES] mingw configure failure detection

2004-05-10 Thread Andrew Dunstan
I said:
 Peter Eisentraut said:
 Andrew Dunstan wrote:
 This patch for configure.in detects the link failures in MINGW that I
 and others have seen and warns the user they have to fix it up.

 I continue to object to these sort of patches if no one wants to
 bother
  to contact the mingw maintainers about this problem.  Maybe they have
 a  better fix available?


 I have already said I would follow it up. But the problem exists today
 and shouldn't be left until we get an answer. Maybe it will take a week
 or a month, or there will be no good answer at all.


It appears that Dann Corbit has filed a MinGW bug on this, with accurate
problem description, but he received a less than stellar response. See

https://sourceforge.net/tracker/index.php?
func=detailaid=931263group_id=2435atid=102435

(Despite previous speculation, he did indicate that the problem is
intermittent, not constant).

Cheers

andrew






---(end of broadcast)---
TIP 8: explain analyze is your friend