Show status via ps command like PostgreSQL
authorTatsuo Ishii <ishii at sraoss.co.jp>
Thu, 1 Feb 2007 13:33:26 +0000 (13:33 +0000)
committerTatsuo Ishii <ishii at sraoss.co.jp>
Thu, 1 Feb 2007 13:33:26 +0000 (13:33 +0000)
(ps_status.c and strlcpy.c are stolen from PostgreSQL)

12 files changed:
Makefile.am
Makefile.in
aclocal.m4
child.c
config.h.in
configure
configure.in
main.c
pool.h
pool_process_query.c
ps_status.c [new file with mode: 0644]
strlcpy.c [new file with mode: 0644]

index df7570430dce7ab5c6d635d671c1e78a5becfcb9..71eb178b5af92001cda6078edb608b2595b011d4 100644 (file)
@@ -4,7 +4,7 @@ pgpool_SOURCES = pool.h version.h pgpool.conf.sample \
        README.euc_jp pgpool.spec \
        main.c child.c pool_auth.c pool_config.l pool_error.c \
        pool_process_query.c pool_stream.c pool_connection_pool.c pool_params.c \
-       pool_signal.h pool_signal.c
+       pool_signal.h pool_signal.c ps_status.c strlcpy.c
 
 DEFS = @DEFS@ \
        -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\"
index 1cc4051eb93ea17e18d6a886892d6bc93e88f50e..6f77c6513db6cf0f9e43fe024a4177f4f5bafb0b 100644 (file)
@@ -1,8 +1,8 @@
-# Makefile.in generated by automake 1.8.5 from Makefile.am.
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004  Free Software Foundation, Inc.
+# 2003, 2004, 2005  Free Software Foundation, Inc.
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,8 +15,6 @@
 @SET_MAKE@
 
 
-SOURCES = $(pgpool_SOURCES)
-
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
@@ -52,28 +50,20 @@ am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
 CONFIG_HEADER = config.h
 CONFIG_CLEAN_FILES =
-am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(sysconfdir)"
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man8dir)" \
+       "$(DESTDIR)$(sysconfdir)"
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
 am_pgpool_OBJECTS = main.$(OBJEXT) child.$(OBJEXT) pool_auth.$(OBJEXT) \
        pool_config.$(OBJEXT) pool_error.$(OBJEXT) \
        pool_process_query.$(OBJEXT) pool_stream.$(OBJEXT) \
        pool_connection_pool.$(OBJEXT) pool_params.$(OBJEXT) \
-       pool_signal.$(OBJEXT)
+       pool_signal.$(OBJEXT) ps_status.$(OBJEXT) strlcpy.$(OBJEXT)
 pgpool_OBJECTS = $(am_pgpool_OBJECTS)
 pgpool_LDADD = $(LDADD)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
-@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/child.Po ./$(DEPDIR)/main.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_auth.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_config.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_connection_pool.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_error.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_params.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_process_query.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_signal.Po \
-@AMDEP_TRUE@   ./$(DEPDIR)/pool_stream.Po
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
        $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
@@ -84,6 +74,12 @@ DIST_SOURCES = $(pgpool_SOURCES)
 man8dir = $(mandir)/man8
 NROFF = nroff
 MANS = $(man_MANS)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
 sysconfDATA_INSTALL = $(INSTALL_DATA)
 DATA = $(sysconf_DATA)
 ETAGS = etags
@@ -154,6 +150,8 @@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
 am__include = @am__include@
 am__leading_dot = @am__leading_dot@
 am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
 bindir = @bindir@
 build_alias = @build_alias@
 datadir = @datadir@
@@ -178,7 +176,7 @@ pgpool_SOURCES = pool.h version.h pgpool.conf.sample \
        README.euc_jp pgpool.spec \
        main.c child.c pool_auth.c pool_config.l pool_error.c \
        pool_process_query.c pool_stream.c pool_connection_pool.c pool_params.c \
-       pool_signal.h pool_signal.c
+       pool_signal.h pool_signal.c ps_status.c strlcpy.c
 
 sysconf_DATA = pgpool.conf.sample
 AM_CPPFLAGS = -Wall -Wmissing-prototypes -Wmissing-declarations -D_GNU_SOURCE
@@ -283,21 +281,21 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_process_query.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_signal.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pool_stream.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ps_status.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Po@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@   if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
 @am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(COMPILE) -c $<
 
 .c.obj:
 @am__fastdepCC_TRUE@   if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
 @am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
-@AMDEP_TRUE@@am__fastdepCC_FALSE@      $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
 
 .l.c:
@@ -355,7 +353,7 @@ install-sysconfDATA: $(sysconf_DATA)
        test -z "$(sysconfdir)" || $(mkdir_p) "$(DESTDIR)$(sysconfdir)"
        @list='$(sysconf_DATA)'; for p in $$list; do \
          if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-         f="`echo $$p | sed -e 's|^.*/||'`"; \
+         f=$(am__strip_dir) \
          echo " $(sysconfDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(sysconfdir)/$$f'"; \
          $(sysconfDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(sysconfdir)/$$f"; \
        done
@@ -363,7 +361,7 @@ install-sysconfDATA: $(sysconf_DATA)
 uninstall-sysconfDATA:
        @$(NORMAL_UNINSTALL)
        @list='$(sysconf_DATA)'; for p in $$list; do \
-         f="`echo $$p | sed -e 's|^.*/||'`"; \
+         f=$(am__strip_dir) \
          echo " rm -f '$(DESTDIR)$(sysconfdir)/$$f'"; \
          rm -f "$(DESTDIR)$(sysconfdir)/$$f"; \
        done
@@ -451,15 +449,15 @@ distdir: $(DISTFILES)
          ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
        || chmod -R a+r $(distdir)
 dist-gzip: distdir
-       $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
        $(am__remove_distdir)
 
 dist-bzip2: distdir
-       $(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
        $(am__remove_distdir)
 
 dist-tarZ: distdir
-       $(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
        $(am__remove_distdir)
 
 dist-shar: distdir
@@ -472,7 +470,7 @@ dist-zip: distdir
        $(am__remove_distdir)
 
 dist dist-all: distdir
-       $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
        $(am__remove_distdir)
 
 # This target untars the dist file and tries a VPATH configuration.  Then
@@ -481,11 +479,11 @@ dist dist-all: distdir
 distcheck: dist
        case '$(DIST_ARCHIVES)' in \
        *.tar.gz*) \
-         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - ;;\
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
        *.tar.bz2*) \
-         bunzip2 -c $(distdir).tar.bz2 | $(AMTAR) xf - ;;\
+         bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
        *.tar.Z*) \
-         uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
        *.shar.gz*) \
          GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
        *.zip*) \
@@ -569,7 +567,7 @@ clean-generic:
        -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
 
 distclean-generic:
-       -rm -f $(CONFIG_CLEAN_FILES)
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
 
 maintainer-clean-generic:
        @echo "This command is intended for maintainers to use"
index 386519138736460822af72f125959e283dd0abc0..20ce300290d9fbd6f2aa7c1970dc6f7e81fa54ad 100644 (file)
@@ -1,7 +1,7 @@
-# generated automatically by aclocal 1.8.5 -*- Autoconf -*-
+# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
-# Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005  Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 # PARTICULAR PURPOSE.
 
-#                                                        -*- Autoconf -*-
-# Copyright (C) 2002, 2003  Free Software Foundation, Inc.
-# Generated from amversion.in; do not edit by hand.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# Copyright (C) 2002, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 # AM_AUTOMAKE_VERSION(VERSION)
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
 # generated from the m4 files accompanying Automake X.Y.
-AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.8"])
+AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
 
 # AM_SET_CURRENT_AUTOMAKE_VERSION
 # -------------------------------
 # Call AM_AUTOMAKE_VERSION so it can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-        [AM_AUTOMAKE_VERSION([1.8.5])])
-
-# AM_AUX_DIR_EXPAND
-
-# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+        [AM_AUTOMAKE_VERSION([1.9.6])])
 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
 # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
 # $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
@@ -106,26 +83,16 @@ AC_PREREQ([2.50])dnl
 am_aux_dir=`cd $ac_aux_dir && pwd`
 ])
 
-# AM_CONDITIONAL                                              -*- Autoconf -*-
-
-# Copyright (C) 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
+# AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 6
+# serial 7
 
 # AM_CONDITIONAL(NAME, SHELL-CONDITION)
 # -------------------------------------
@@ -145,30 +112,19 @@ else
 fi
 AC_CONFIG_COMMANDS_PRE(
 [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
-  AC_MSG_ERROR([conditional "$1" was never defined.
-Usually this means the macro was only invoked conditionally.])
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# serial 7                                             -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
 # Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
+# serial 8
 
 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
 # written in clear, in which case automake, when reading aclocal.m4,
@@ -177,7 +133,6 @@ fi])])
 # CC etc. in the Makefile, will ask for an AC_PROG_CC use...
 
 
-
 # _AM_DEPENDENCIES(NAME)
 # ----------------------
 # See how the compiler implements dependency checking.
@@ -317,26 +272,16 @@ AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
 AC_SUBST([AMDEPBACKSLASH])
 ])
 
-# Generate code to set up dependency tracking.   -*- Autoconf -*-
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-#serial 2
+#serial 3
 
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
@@ -355,27 +300,21 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
   else
     continue
   fi
-  grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
-  # Extract the definition of DEP_FILES from the Makefile without
-  # running `make'.
+  # Extract the definition of DEPDIR, am__include, and am__quote
+  # from the Makefile without running `make'.
   DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
   test -z "$DEPDIR" && continue
+  am__include=`sed -n 's/^am__include = //p' < "$mf"`
+  test -z "am__include" && continue
+  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
   # When using ansi2knr, U may be empty or an underscore; expand it
   U=`sed -n 's/^U = //p' < "$mf"`
-  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
-  # We invoke sed twice because it is the simplest approach to
-  # changing $(DEPDIR) to its actual value in the expansion.
-  for file in `sed -n '
-    /^DEP_FILES = .*\\\\$/ {
-      s/^DEP_FILES = //
-      :loop
-       s/\\\\$//
-       p
-       n
-       /\\\\$/ b loop
-      p
-    }
-    /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+  # Find all dependency output files, they are included files with
+  # $(DEPDIR) in their names.  We invoke sed twice because it is the
+  # simplest approach to changing $(DEPDIR) to its actual value in the
+  # expansion.
+  for file in `sed -n "
+    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
     # Make sure the directory exists.
     test -f "$dirpart/$file" && continue
@@ -401,54 +340,31 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 ])
 
-# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 7
+# serial 8
 
 # AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
 AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
 
-# Do all the work for Automake.                            -*- Autoconf -*-
+# Do all the work for Automake.                             -*- Autoconf -*-
 
-# This macro actually does too much some checks are only needed if
-# your package does certain things.  But this isn't really a big deal.
-
-# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
 # Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# serial 12
 
-# serial 11
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
 
 # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
 # AM_INIT_AUTOMAKE([OPTIONS])
@@ -506,7 +422,6 @@ AM_MISSING_PROG(AUTOCONF, autoconf)
 AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
 AM_MISSING_PROG(AUTOHEADER, autoheader)
 AM_MISSING_PROG(MAKEINFO, makeinfo)
-AM_MISSING_PROG(AMTAR, tar)
 AM_PROG_INSTALL_SH
 AM_PROG_INSTALL_STRIP
 AC_REQUIRE([AM_PROG_MKDIR_P])dnl
@@ -515,7 +430,9 @@ AC_REQUIRE([AM_PROG_MKDIR_P])dnl
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
 AC_REQUIRE([AM_SET_LEADING_DOT])dnl
-
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+              [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+                            [_AM_PROG_TAR([v7])])])
 _AM_IF_OPTION([no-dependencies],,
 [AC_PROVIDE_IFELSE([AC_PROG_CC],
                   [_AM_DEPENDENCIES(CC)],
@@ -549,51 +466,27 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
 
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
 # AM_PROG_INSTALL_SH
 # ------------------
 # Define $install_sh.
-
-# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 install_sh=${install_sh-"$am_aux_dir/install-sh"}
 AC_SUBST(install_sh)])
 
-#                                                          -*- Autoconf -*-
-# Copyright (C) 2003  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 1
+# serial 2
 
 # Check whether the underlying file-system supports filenames
 # with a leading dot.  For instance MS-DOS doesn't.
@@ -608,26 +501,14 @@ fi
 rmdir .tst 2>/dev/null
 AC_SUBST([am__leading_dot])])
 
-
-# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
+# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005
 # Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
-# serial 4
+# serial 5
 
 # AM_PROG_LEX
 # -----------
@@ -641,26 +522,15 @@ if test "$LEX" = :; then
   LEX=${am_missing_run}flex
 fi])
 
-# Check to see how 'make' treats includes.     -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
+# Check to see how 'make' treats includes.                 -*- Autoconf -*-
 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 2
+# serial 3
 
 # AM_MAKE_INCLUDE()
 # -----------------
@@ -704,27 +574,16 @@ AC_MSG_RESULT([$_am_result])
 rm -f confinc confmf
 ])
 
-#  -*- Autoconf -*-
-
-
-# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 3
+# serial 4
 
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
@@ -750,27 +609,16 @@ else
 fi
 ])
 
+# Copyright (C) 2003, 2004, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
 # AM_PROG_MKDIR_P
 # ---------------
 # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
-
-# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
-
+#
 # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
 # created by `make install' are always world readable, even if the
 # installer happens to have an overly restrictive umask (e.g. 077).
@@ -791,13 +639,21 @@ fi
 # this.)
 AC_DEFUN([AM_PROG_MKDIR_P],
 [if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
-  # Keeping the `.' argument allows $(mkdir_p) to be used without
-  # argument.  Indeed, we sometimes output rules like
+  # We used to keeping the `.' as first argument, in order to
+  # allow $(mkdir_p) to be used without argument.  As in
   #   $(mkdir_p) $(somedir)
-  # where $(somedir) is conditionally defined.
-  # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more
-  # expensive solution, as it forces Make to start a sub-shell.)
-  mkdir_p='mkdir -p -- .'
+  # where $(somedir) is conditionally defined.  However this is wrong
+  # for two reasons:
+  #  1. if the package is installed by a user who cannot write `.'
+  #     make install will fail,
+  #  2. the above comment should most certainly read
+  #     $(mkdir_p) $(DESTDIR)$(somedir)
+  #     so it does not work when $(somedir) is undefined and
+  #     $(DESTDIR) is not.
+  #  To support the latter case, we have to write
+  #     test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
+  #  so the `.' trick is pointless.
+  mkdir_p='mkdir -p --'
 else
   # On NextStep and OpenStep, the `mkdir' command does not
   # recognize any option.  It will interpret all options as
@@ -816,26 +672,15 @@ else
 fi
 AC_SUBST([mkdir_p])])
 
-# Helper functions for option handling.                    -*- Autoconf -*-
-
-# Copyright (C) 2001, 2002, 2003  Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# Helper functions for option handling.                     -*- Autoconf -*-
 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 2001, 2002, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 2
+# serial 3
 
 # _AM_MANGLE_OPTION(NAME)
 # -----------------------
@@ -860,28 +705,16 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-#
-# Check to make sure that the build environment is sane.
-#
-
-# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
-# serial 3
+# serial 4
 
 # AM_SANITY_CHECK
 # ---------------
@@ -924,25 +757,14 @@ Check your system clock])
 fi
 AC_MSG_RESULT(yes)])
 
-# AM_PROG_INSTALL_STRIP
-
-# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-# 02111-1307, USA.
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
 
+# AM_PROG_INSTALL_STRIP
+# ---------------------
 # One issue with vendor `install' (even GNU) is that you can't
 # specify the program used to strip binaries.  This is especially
 # annoying in cross-compiling environments, where the build's strip
@@ -963,3 +785,99 @@ fi
 INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
diff --git a/child.c b/child.c
index fe96aa5c70e573550fa11e41fe20089fbe527f38..40b466dcc5412752349e60949d6b2acbf6908a48 100644 (file)
--- a/child.c
+++ b/child.c
@@ -68,6 +68,9 @@ static int exit_request;
 
 static int idle;               /* non 0 means this child is in idle state */
 
+extern int myargc;
+extern char **myargv;
+
 /*
 * child main loop
 */
@@ -86,6 +89,9 @@ void do_child(int unix_fd, int inet_fd)
 
        pool_debug("I am %d", getpid());
 
+       /* Identify myself via ps */
+       init_ps_display("", "", "", "");
+
        /* set up signal handlers */
        signal(SIGALRM, SIG_DFL);
        signal(SIGTERM, die);
@@ -128,6 +134,7 @@ void do_child(int unix_fd, int inet_fd)
                int connection_reuse = 1;
                int ssl_request = 0;
                StartupPacket *sp;
+               char psbuf[128];
 
                /* pgpool stop request already sent? */
                if (exit_request)
@@ -326,6 +333,9 @@ void do_child(int unix_fd, int inet_fd)
                        pool_enable_timeout();
 
                connected = 1;
+               sp = MASTER_CONNECTION(backend)->sp;
+               snprintf(psbuf, sizeof(psbuf), "%s %s", sp->database, sp->user);
+               set_ps_display(psbuf, false);
 
                /* query process loop */
                for (;;)
@@ -494,6 +504,8 @@ static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *time
        struct timeval *timeoutval;
        struct timeval tv1, tv2, tmback;
 
+       set_ps_display("wait for connection request", false);
+
        FD_ZERO(&readmask);
        FD_SET(unix_fd, &readmask);
        if (inet_fd)
@@ -603,6 +615,7 @@ static POOL_CONNECTION *do_accept(int unix_fd, int inet_fd, struct timeval *time
                pool_log("cnt: %d atime: %ld", cnt, atime);
        }
 #endif
+       set_ps_display("accept connection", false);
        pool_debug("I am %d accept fd %d", getpid(), afd);
 
        /* set NODELAY and KEEPALIVE options if INET connection */
index 0c0539057c147496bb626696c5c30d206f3a9c33..44d2ad3963f43d71d9154e55fc1d50507cdfa0a7 100644 (file)
@@ -57,6 +57,9 @@
 /* Define to 1 if you have the `select' function. */
 #undef HAVE_SELECT
 
+/* Define to 1 if you have the `setproctitle' function. */
+#undef HAVE_SETPROCTITLE
+
 /* Define to 1 if you have the `setsid' function. */
 #undef HAVE_SETSID
 
@@ -93,6 +96,9 @@
 /* Define to 1 if you have the <sys/param.h> header file. */
 #undef HAVE_SYS_PARAM_H
 
+/* Define to 1 if you have the <sys/pstat.h> header file. */
+#undef HAVE_SYS_PSTAT_H
+
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
index 25efc478ceefb4a79f5ba392da98a89726aa7d73..e4de826e947d00cef5389634e541a385a2bab8d6 100755 (executable)
--- a/configure
+++ b/configure
@@ -308,7 +308,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE LEX LEXLIB LEX_OUTPUT_ROOT CPP EGREP PGSQL_INCLUDE_DIR LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE LEX LEXLIB LEX_OUTPUT_ROOT CPP EGREP PGSQL_INCLUDE_DIR LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -2231,7 +2231,7 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
-am__api_version="1.8"
+am__api_version="1.9"
 ac_aux_dir=
 for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
   if test -f $ac_dir/install-sh; then
@@ -2408,13 +2408,21 @@ echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
 fi
 
 if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
-  # Keeping the `.' argument allows $(mkdir_p) to be used without
-  # argument.  Indeed, we sometimes output rules like
+  # We used to keeping the `.' as first argument, in order to
+  # allow $(mkdir_p) to be used without argument.  As in
   #   $(mkdir_p) $(somedir)
-  # where $(somedir) is conditionally defined.
-  # (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more
-  # expensive solution, as it forces Make to start a sub-shell.)
-  mkdir_p='mkdir -p -- .'
+  # where $(somedir) is conditionally defined.  However this is wrong
+  # for two reasons:
+  #  1. if the package is installed by a user who cannot write `.'
+  #     make install will fail,
+  #  2. the above comment should most certainly read
+  #     $(mkdir_p) $(DESTDIR)$(somedir)
+  #     so it does not work when $(somedir) is undefined and
+  #     $(DESTDIR) is not.
+  #  To support the latter case, we have to write
+  #     test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
+  #  so the `.' trick is pointless.
+  mkdir_p='mkdir -p --'
 else
   # On NextStep and OpenStep, the `mkdir' command does not
   # recognize any option.  It will interpret all options as
@@ -2623,9 +2631,6 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
 
 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 
-
-AMTAR=${AMTAR-"${am_missing_run}tar"}
-
 install_sh=${install_sh-"$am_aux_dir/install-sh"}
 
 # Installed binaries are usually stripped using `strip' when the user
@@ -2718,6 +2723,13 @@ INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
 
 # We need awk for the "check" target.  The system "awk" is bad on
 # some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
 
 
 depcc="$CC"   am_compiler_list=
@@ -4426,7 +4438,8 @@ done
 
 
 
-for ac_header in fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h sys/param.h sys/types.h sys/time.h
+
+for ac_header in fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h sys/param.h sys/types.h sys/time.h sys/pstat.h
 do
 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
 if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -5177,7 +5190,8 @@ fi
 
 
 
-for ac_func in setsid select socket sigprocmask strdup strerror strftime strtok asprintf
+
+for ac_func in setsid select socket sigprocmask strdup strerror strftime strtok asprintf setproctitle
 do
 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
 echo "$as_me:$LINENO: checking for $ac_func" >&5
@@ -5957,7 +5971,6 @@ s,@AUTOCONF@,$AUTOCONF,;t t
 s,@AUTOMAKE@,$AUTOMAKE,;t t
 s,@AUTOHEADER@,$AUTOHEADER,;t t
 s,@MAKEINFO@,$MAKEINFO,;t t
-s,@AMTAR@,$AMTAR,;t t
 s,@install_sh@,$install_sh,;t t
 s,@STRIP@,$STRIP,;t t
 s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t
@@ -5966,6 +5979,9 @@ s,@mkdir_p@,$mkdir_p,;t t
 s,@AWK@,$AWK,;t t
 s,@SET_MAKE@,$SET_MAKE,;t t
 s,@am__leading_dot@,$am__leading_dot,;t t
+s,@AMTAR@,$AMTAR,;t t
+s,@am__tar@,$am__tar,;t t
+s,@am__untar@,$am__untar,;t t
 s,@DEPDIR@,$DEPDIR,;t t
 s,@am__include@,$am__include,;t t
 s,@am__quote@,$am__quote,;t t
@@ -6605,27 +6621,21 @@ echo X"$mf" |
   else
     continue
   fi
-  grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue
-  # Extract the definition of DEP_FILES from the Makefile without
-  # running `make'.
+  # Extract the definition of DEPDIR, am__include, and am__quote
+  # from the Makefile without running `make'.
   DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
   test -z "$DEPDIR" && continue
+  am__include=`sed -n 's/^am__include = //p' < "$mf"`
+  test -z "am__include" && continue
+  am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
   # When using ansi2knr, U may be empty or an underscore; expand it
   U=`sed -n 's/^U = //p' < "$mf"`
-  test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
-  # We invoke sed twice because it is the simplest approach to
-  # changing $(DEPDIR) to its actual value in the expansion.
-  for file in `sed -n '
-    /^DEP_FILES = .*\\\\$/ {
-      s/^DEP_FILES = //
-      :loop
-       s/\\\\$//
-       p
-       n
-       /\\\\$/ b loop
-      p
-    }
-    /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
+  # Find all dependency output files, they are included files with
+  # $(DEPDIR) in their names.  We invoke sed twice because it is the
+  # simplest approach to changing $(DEPDIR) to its actual value in the
+  # expansion.
+  for file in `sed -n "
+    s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
     # Make sure the directory exists.
     test -f "$dirpart/$file" && continue
index 65294acd056dcb53fda793f8a7827ae2abbbe44f..7a2fea2e4e5b7041f5a42687f5ebd9f163a83cc1 100644 (file)
@@ -24,7 +24,7 @@ AC_CHECK_LIB(resolv,   main)
 dnl Checks for header files.
 AC_HEADER_STDC
 AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h sys/param.h sys/types.h sys/time.h)
+AC_CHECK_HEADERS(fcntl.h unistd.h getopt.h netinet/tcp.h netinet/in.h sys/param.h sys/types.h sys/time.h sys/pstat.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
@@ -35,7 +35,7 @@ dnl Checks for library functions.
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
 AC_FUNC_WAIT3
-AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf)
+AC_CHECK_FUNCS(setsid select socket sigprocmask strdup strerror strftime strtok asprintf setproctitle)
 
 PGSQL_INCLUDE_DIR=/usr/local/pgsql/include
 AC_ARG_WITH(pgsql,
diff --git a/main.c b/main.c
index 6de83032f002cd8e7ba23efbfe9dae1104254731..b926bf2d7ecb3ebc79a4b3d236040a2e4a843f5a 100644 (file)
--- a/main.c
+++ b/main.c
@@ -87,6 +87,9 @@ static int switch_over_sig = SIGUSR1; /* switch over signal default value */
 
 static int health_check_timer_expired;         /* non 0 if health check timer expired */
 
+int myargc;
+char **myargv;
+
 /*
 * pgpool main program
 */
@@ -97,6 +100,9 @@ int main(int argc, char **argv)
        int i;
        int pid;
 
+       myargc = argc;
+       myargv = argv;
+
        snprintf(conf_file, sizeof(conf_file), "%s/%s", DEFAULT_CONFIGDIR, POOL_CONF_FILE_NAME);
 
        while ((opt = getopt(argc, argv, "df:hm:ns:")) != -1)
@@ -512,7 +518,7 @@ static void write_pid_file(void)
 /*
 * fork a child
 */
-pid_t fork_a_child(int unix_fd, int inet_fd)
+static pid_t fork_a_child(int unix_fd, int inet_fd)
 {
        pid_t pid;
 
@@ -520,6 +526,8 @@ pid_t fork_a_child(int unix_fd, int inet_fd)
 
        if (pid == 0)
        {
+               myargv = save_ps_display_args(myargc, myargv);
+
                /* call child main */
                POOL_SETMASK(&UnBlockSig);
                do_child(unix_fd, inet_fd);
diff --git a/pool.h b/pool.h
index f8b4a99c8e1185487de8f094663d8ffb5a965e5b..5d23eab8bdf98b7e91eab8d6581d4dc8dbc7e51e 100644 (file)
--- a/pool.h
+++ b/pool.h
 #include <stdio.h>
 #include <time.h>
 
+/* typdefs */
+#ifndef __cplusplus
+#ifndef bool
+typedef char bool;
+#endif
+
+#ifndef true
+#define true   ((bool) 1)
+#endif
+
+#ifndef false
+#define false  ((bool) 0)
+#endif
+
+#endif
+
 /* undef this if you have problems with non blocking accept() */
 #define NONE_BLOCK
 
@@ -339,4 +355,17 @@ extern int health_check(void);
 
 extern void init_prepared_list(void);
 
+extern size_t strlcpy(char *dst, const char *src, size_t siz);
+
+extern bool update_process_title;
+
+extern char **save_ps_display_args(int argc, char **argv);
+
+extern void init_ps_display(const char *username, const char *dbname,
+                               const char *host_info, const char *initial_str);
+
+extern void set_ps_display(const char *activity, bool force);
+
+extern const char *get_ps_display(int *displen);
+
 #endif /* POOL_H */
index 056bb5e9b105f8ffb042ff07c58a4de904f72fca..c24ce3c5b257212019a279e93ca9226e26c86a59 100644 (file)
@@ -150,6 +150,7 @@ static PreparedStatementList prepared_list; /* prepared statement name list */
 static PreparedStatement *unnamed_statement = NULL;
 static PreparedStatement *unnamed_portal = NULL;
 static int is_drop_database(char *query);              /* returns non 0 if this is a DROP DATABASE command */
+static void query_ps_status(char *query, POOL_CONNECTION_POOL *backend);               /* show ps status */
 
 POOL_STATUS pool_process_query(POOL_CONNECTION *frontend, 
                                                           POOL_CONNECTION_POOL *backend,
@@ -585,6 +586,9 @@ static POOL_STATUS Query(POOL_CONNECTION *frontend,
                string = query;
        }
 
+       /* show ps status */
+       query_ps_status(string, backend);
+
        /* log query to log file if neccessary */
        if (pool_config.log_statement)
        {
@@ -955,6 +959,9 @@ static POOL_STATUS Sync(POOL_CONNECTION *frontend,
 static POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend, 
                                                                 POOL_CONNECTION_POOL *backend, int send_ready)
 {
+       StartupPacket *sp;
+       char psbuf[1024];
+
        /* if a transaction is started for insert lock, we need to close it. */
        if (internal_transaction_started)
        {
@@ -1037,6 +1044,16 @@ static POOL_STATUS ReadyForQuery(POOL_CONNECTION *frontend,
 #ifdef NOT_USED
        return ProcessFrontendResponse(frontend, backend);
 #endif
+
+       sp = MASTER_CONNECTION(backend)->sp;
+       if (MASTER(backend)->tstate == 'T')
+               snprintf(psbuf, sizeof(psbuf), "%s %s idle in transaction", 
+                                sp->database, sp->user);
+       else
+               snprintf(psbuf, sizeof(psbuf), "%s %s idle", 
+                                sp->database, sp->user);
+       set_ps_display(psbuf, false);
+
        return POOL_CONTINUE;
 }
 
@@ -3658,3 +3675,34 @@ static char *normalize_prepared_stmt_name(const char *name)
 
        return result;
 }
+
+static void query_ps_status(char *query, POOL_CONNECTION_POOL *backend)
+{
+       StartupPacket *sp;
+       char psbuf[1024];
+       int i;
+
+       /* skip comment */
+    query = skip_comment(query);
+
+       if (*query == '\0')
+               return;
+
+       sp = MASTER_CONNECTION(backend)->sp;
+       i = snprintf(psbuf, sizeof(psbuf), "%s %s ", sp->database, sp->user);
+
+       /* skip spaces */
+       while (*query && isspace(*query))
+               query++;
+
+       for (; i< sizeof(psbuf); i++)
+       {
+               if (!*query || isspace(*query))
+                       break;
+
+               psbuf[i] = toupper(*query++);
+       }
+       psbuf[i] = '\0';
+
+       set_ps_display(psbuf, false);
+}
diff --git a/ps_status.c b/ps_status.c
new file mode 100644 (file)
index 0000000..8a4c021
--- /dev/null
@@ -0,0 +1,374 @@
+/*--------------------------------------------------------------------
+ * ps_status.c
+ *
+ * Routines to support changing the ps display of PostgreSQL backends
+ * to contain some useful information. Mechanism differs wildly across
+ * platforms.
+ *
+ * $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.33 2006/10/04 00:30:04 momjian Exp $
+ *
+ * Copyright (c) 2000-2006, PostgreSQL Global Development Group
+ * various details abducted from various places
+ *--------------------------------------------------------------------
+ */
+
+#include <unistd.h>
+#ifdef HAVE_SYS_PSTAT_H
+#include <sys/pstat.h>                 /* for HP-UX */
+#endif
+#ifdef HAVE_PS_STRINGS
+#include <machine/vmparam.h>   /* for old BSD */
+#include <sys/exec.h>
+#endif
+#if defined(__darwin__)
+#include <crt_externs.h>
+#endif
+
+#include "pool.h"
+#include <stdlib.h>
+#include <string.h>
+
+extern char **environ;
+bool           update_process_title = true;
+
+
+/*
+ * Alternative ways of updating ps display:
+ *
+ * PS_USE_SETPROCTITLE
+ *        use the function setproctitle(const char *, ...)
+ *        (newer BSD systems)
+ * PS_USE_PSTAT
+ *        use the pstat(PSTAT_SETCMD, )
+ *        (HPUX)
+ * PS_USE_PS_STRINGS
+ *        assign PS_STRINGS->ps_argvstr = "string"
+ *        (some BSD systems)
+ * PS_USE_CHANGE_ARGV
+ *        assign argv[0] = "string"
+ *        (some other BSD systems)
+ * PS_USE_CLOBBER_ARGV
+ *        write over the argv and environment area
+ *        (most SysV-like systems)
+ * PS_USE_WIN32
+ *        push the string out as the name of a Windows event
+ * PS_USE_NONE
+ *        don't update ps display
+ *        (This is the default, as it is safest.)
+ */
+#if defined(HAVE_SETPROCTITLE)
+#define PS_USE_SETPROCTITLE
+#elif defined(HAVE_PSTAT) && defined(PSTAT_SETCMD)
+#define PS_USE_PSTAT
+#elif defined(HAVE_PS_STRINGS)
+#define PS_USE_PS_STRINGS
+#elif (defined(BSD) || defined(__bsdi__) || defined(__hurd__)) && !defined(__darwin__)
+#define PS_USE_CHANGE_ARGV
+#elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__)
+#define PS_USE_CLOBBER_ARGV
+#elif defined(WIN32)
+#define PS_USE_WIN32
+#else
+#define PS_USE_NONE
+#endif
+
+
+/* Different systems want the buffer padded differently */
+#if defined(_AIX) || defined(__linux__) || defined(__svr4__)
+#define PS_PADDING '\0'
+#else
+#define PS_PADDING ' '
+#endif
+
+
+#ifndef PS_USE_CLOBBER_ARGV
+/* all but one options need a buffer to write their ps line in */
+#define PS_BUFFER_SIZE 256
+static char ps_buffer[PS_BUFFER_SIZE];
+static const size_t ps_buffer_size = PS_BUFFER_SIZE;
+#else                                                  /* PS_USE_CLOBBER_ARGV */
+static char *ps_buffer;                        /* will point to argv area */
+static size_t ps_buffer_size;  /* space determined at run time */
+#endif   /* PS_USE_CLOBBER_ARGV */
+
+static size_t ps_buffer_fixed_size;            /* size of the constant prefix */
+
+/* save the original argv[] location here */
+static int     save_argc;
+static char **save_argv;
+
+
+/*
+ * Call this early in startup to save the original argc/argv values.
+ * If needed, we make a copy of the original argv[] array to preserve it
+ * from being clobbered by subsequent ps_display actions.
+ *
+ * (The original argv[] will not be overwritten by this routine, but may be
+ * overwritten during init_ps_display. Also, the physical location of the
+ * environment strings may be moved, so this should be called before any code
+ * that might try to hang onto a getenv() result.)
+ */
+char     **
+save_ps_display_args(int argc, char **argv)
+{
+       save_argc = argc;
+       save_argv = argv;
+
+#if defined(PS_USE_CLOBBER_ARGV)
+
+       /*
+        * If we're going to overwrite the argv area, count the available space.
+        * Also move the environment to make additional room.
+        */
+       {
+               char       *end_of_area = NULL;
+               char      **new_environ;
+               int                     i;
+
+               /*
+                * check for contiguous argv strings
+                */
+               for (i = 0; i < argc; i++)
+               {
+                       if (i == 0 || end_of_area + 1 == argv[i])
+                               end_of_area = argv[i] + strlen(argv[i]);
+               }
+
+               if (end_of_area == NULL)        /* probably can't happen? */
+               {
+                       ps_buffer = NULL;
+                       ps_buffer_size = 0;
+                       return argv;
+               }
+
+               /*
+                * check for contiguous environ strings following argv
+                */
+               for (i = 0; environ[i] != NULL; i++)
+               {
+                       if (end_of_area + 1 == environ[i])
+                               end_of_area = environ[i] + strlen(environ[i]);
+               }
+
+               ps_buffer = argv[0];
+               ps_buffer_size = end_of_area - argv[0];
+
+               /*
+                * move the environment out of the way
+                */
+               new_environ = (char **) malloc((i + 1) * sizeof(char *));
+               for (i = 0; environ[i] != NULL; i++)
+                       new_environ[i] = strdup(environ[i]);
+               new_environ[i] = NULL;
+               environ = new_environ;
+       }
+#endif   /* PS_USE_CLOBBER_ARGV */
+
+#if defined(PS_USE_CHANGE_ARGV) || defined(PS_USE_CLOBBER_ARGV)
+
+       /*
+        * If we're going to change the original argv[] then make a copy for
+        * argument parsing purposes.
+        *
+        * (NB: do NOT think to remove the copying of argv[], even though
+        * postmaster.c finishes looking at argv[] long before we ever consider
+        * changing the ps display.  On some platforms, getopt() keeps pointers
+        * into the argv array, and will get horribly confused when it is
+        * re-called to analyze a subprocess' argument string if the argv storage
+        * has been clobbered meanwhile.  Other platforms have other dependencies
+        * on argv[].
+        */
+       {
+               char      **new_argv;
+               int                     i;
+
+               new_argv = (char **) malloc((argc + 1) * sizeof(char *));
+               for (i = 0; i < argc; i++)
+                       new_argv[i] = strdup(argv[i]);
+               new_argv[argc] = NULL;
+
+#if defined(__darwin__)
+
+               /*
+                * Darwin (and perhaps other NeXT-derived platforms?) has a static
+                * copy of the argv pointer, which we may fix like so:
+                */
+               *_NSGetArgv() = new_argv;
+#endif
+
+               argv = new_argv;
+       }
+#endif   /* PS_USE_CHANGE_ARGV or PS_USE_CLOBBER_ARGV */
+
+       return argv;
+}
+
+/*
+ * Call this once during subprocess startup to set the identification
+ * values.     At this point, the original argv[] array may be overwritten.
+ */
+void
+init_ps_display(const char *username, const char *dbname,
+                               const char *host_info, const char *initial_str)
+{
+#ifndef PS_USE_NONE
+       /* no ps display if you didn't call save_ps_display_args() */
+       if (!save_argv)
+               return;
+#ifdef PS_USE_CLOBBER_ARGV
+       /* If ps_buffer is a pointer, it might still be null */
+       if (!ps_buffer)
+               return;
+#endif
+
+       /*
+        * Overwrite argv[] to point at appropriate space, if needed
+        */
+
+#ifdef PS_USE_CHANGE_ARGV
+       save_argv[0] = ps_buffer;
+       save_argv[1] = NULL;
+#endif   /* PS_USE_CHANGE_ARGV */
+
+#ifdef PS_USE_CLOBBER_ARGV
+       {
+               int                     i;
+
+               /* make extra argv slots point at end_of_area (a NUL) */
+               for (i = 1; i < save_argc; i++)
+                       save_argv[i] = ps_buffer + ps_buffer_size;
+       }
+#endif   /* PS_USE_CLOBBER_ARGV */
+
+       /*
+        * Make fixed prefix of ps display.
+        */
+
+#ifdef PS_USE_SETPROCTITLE
+
+       /*
+        * apparently setproctitle() already adds a `progname:' prefix to the ps
+        * line
+        */
+       snprintf(ps_buffer, ps_buffer_size,
+                        "%s %s %s ",
+                        username, dbname, host_info);
+#else
+       snprintf(ps_buffer, ps_buffer_size,
+                        "pgpool: ");
+#endif
+
+       ps_buffer_fixed_size = strlen(ps_buffer);
+
+       set_ps_display(initial_str, true);
+#endif   /* not PS_USE_NONE */
+}
+
+
+
+/*
+ * Call this to update the ps status display to a fixed prefix plus an
+ * indication of what you're currently doing passed in the argument.
+ */
+void
+set_ps_display(const char *activity, bool force)
+{
+
+       if (!force && !update_process_title)
+               return;
+
+#ifndef PS_USE_NONE
+
+#ifdef PS_USE_CLOBBER_ARGV
+       /* If ps_buffer is a pointer, it might still be null */
+       if (!ps_buffer)
+               return;
+#endif
+
+       /* Update ps_buffer to contain both fixed part and activity */
+       strlcpy(ps_buffer + ps_buffer_fixed_size, activity,
+                       ps_buffer_size - ps_buffer_fixed_size);
+
+       /* Transmit new setting to kernel, if necessary */
+
+#ifdef PS_USE_SETPROCTITLE
+       setproctitle("%s", ps_buffer);
+#endif
+
+#ifdef PS_USE_PSTAT
+       {
+               union pstun pst;
+
+               pst.pst_command = ps_buffer;
+               pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0);
+       }
+#endif   /* PS_USE_PSTAT */
+
+#ifdef PS_USE_PS_STRINGS
+       PS_STRINGS->ps_nargvstr = 1;
+       PS_STRINGS->ps_argvstr = ps_buffer;
+#endif   /* PS_USE_PS_STRINGS */
+
+#ifdef PS_USE_CLOBBER_ARGV
+       {
+               int                     buflen;
+
+               /* pad unused memory */
+               buflen = strlen(ps_buffer);
+               memset(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen);
+       }
+#endif   /* PS_USE_CLOBBER_ARGV */
+
+#ifdef PS_USE_WIN32
+       {
+               /*
+                * Win32 does not support showing any changed arguments. To make it at
+                * all possible to track which backend is doing what, we create a
+                * named object that can be viewed with for example Process Explorer.
+                */
+               static HANDLE ident_handle = INVALID_HANDLE_VALUE;
+               char            name[PS_BUFFER_SIZE + 32];
+
+               if (ident_handle != INVALID_HANDLE_VALUE)
+                       CloseHandle(ident_handle);
+
+               sprintf(name, "pgident: %s", ps_buffer);
+
+               ident_handle = CreateEvent(NULL, TRUE, FALSE, name);
+       }
+#endif   /* PS_USE_WIN32 */
+#endif   /* not PS_USE_NONE */
+}
+
+
+/*
+ * Returns what's currently in the ps display, in case someone needs
+ * it. Note that only the activity part is returned.  On some platforms
+ * the string will not be null-terminated, so return the effective
+ * length into *displen.
+ */
+const char *
+get_ps_display(int *displen)
+{
+#ifdef PS_USE_CLOBBER_ARGV
+       size_t          offset;
+
+       /* If ps_buffer is a pointer, it might still be null */
+       if (!ps_buffer)
+       {
+               *displen = 0;
+               return "";
+       }
+
+       /* Remove any trailing spaces to offset the effect of PS_PADDING */
+       offset = ps_buffer_size;
+       while (offset > ps_buffer_fixed_size && ps_buffer[offset - 1] == PS_PADDING)
+               offset--;
+
+       *displen = offset - ps_buffer_fixed_size;
+#else
+       *displen = strlen(ps_buffer + ps_buffer_fixed_size);
+#endif
+
+       return ps_buffer + ps_buffer_fixed_size;
+}
diff --git a/strlcpy.c b/strlcpy.c
new file mode 100644 (file)
index 0000000..23ce07f
--- /dev/null
+++ b/strlcpy.c
@@ -0,0 +1,71 @@
+/*-------------------------------------------------------------------------
+ *
+ * strlcpy.c
+ *       strncpy done right
+ *
+ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
+ *
+ *
+ * IDENTIFICATION
+ *       $PostgreSQL: pgsql/src/port/strlcpy.c,v 1.3 2006/10/04 00:30:14 momjian Exp $
+ *
+ * This file was taken from OpenBSD and is used on platforms that don't
+ * provide strlcpy().  The OpenBSD copyright terms follow.
+ *-------------------------------------------------------------------------
+ */
+
+/*     $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $    */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <unistd.h>
+#include "pool.h"
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied.     Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ * Function creation history:  http://www.gratisoft.us/todd/papers/strlcpy.html
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+       char       *d = dst;
+       const char *s = src;
+       size_t          n = siz;
+
+       /* Copy as many bytes as will fit */
+       if (n != 0)
+       {
+               while (--n != 0)
+               {
+                       if ((*d++ = *s++) == '\0')
+                               break;
+               }
+       }
+
+       /* Not enough room in dst, add NUL and traverse rest of src */
+       if (n == 0)
+       {
+               if (siz != 0)
+                       *d = '\0';                      /* NUL-terminate dst */
+               while (*s++)
+                       ;
+       }
+
+       return (s - src - 1);           /* count does not include NUL */
+}