From 379268aa62f6aed0ec03ed59e007f3f337b30dd7 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 19 Oct 2001 20:47:09 +0000 Subject: [PATCH] Proper fix for glibc getopt() botch. Surprising we did not see this before. --- configure | 149 +++++++++++++++++----------- configure.in | 9 ++ src/backend/postmaster/postmaster.c | 44 +++++--- src/include/pg_config.h.in | 5 +- 4 files changed, 132 insertions(+), 75 deletions(-) diff --git a/configure b/configure index a443484cf4..2693830963 100755 --- a/configure +++ b/configure @@ -7475,22 +7475,55 @@ EOF fi +echo $ac_n "checking for __getopt_initialized""... $ac_c" 1>&6 +echo "configure:7480: checking for __getopt_initialized" >&5 +if eval "test \"`echo '$''{'pgac_cv_var_int___getopt_initialized'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { +extern int __getopt_initialized; __getopt_initialized = 1; +; return 0; } +EOF +if { (eval echo configure:7492: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + pgac_cv_var_int___getopt_initialized=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + pgac_cv_var_int___getopt_initialized=no +fi +rm -f conftest* +fi + +echo "$ac_t""$pgac_cv_var_int___getopt_initialized" 1>&6 +if test x"$pgac_cv_var_int___getopt_initialized" = x"yes"; then + cat >> confdefs.h <<\EOF +#define HAVE_INT___GETOPT_INITIALIZED 1 +EOF + +fi + # This test makes sure that run tests work at all. Sometimes a shared # library is found by the linker, but the runtime linker can't find it. # This check should come after all modifications of compiler or linker # variables, and before any other run tests. echo $ac_n "checking test program""... $ac_c" 1>&6 -echo "configure:7485: checking test program" >&5 +echo "configure:7518: checking test program" >&5 if test "$cross_compiling" = yes; then echo "$ac_t""cross-compiling" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7527: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""ok" 1>&6 else @@ -7510,7 +7543,7 @@ fi echo $ac_n "checking whether long int is 64 bits""... $ac_c" 1>&6 -echo "configure:7514: checking whether long int is 64 bits" >&5 +echo "configure:7547: checking whether long int is 64 bits" >&5 if eval "test \"`echo '$''{'pgac_cv_type_long_int_64'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7519,7 +7552,7 @@ else echo "configure: warning: 64 bit arithmetic disabled when cross-compiling" 1>&2 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7585: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then pgac_cv_type_long_int_64=yes else @@ -7575,7 +7608,7 @@ fi if test x"$HAVE_LONG_INT_64" = x"no" ; then echo $ac_n "checking whether long long int is 64 bits""... $ac_c" 1>&6 -echo "configure:7579: checking whether long long int is 64 bits" >&5 +echo "configure:7612: checking whether long long int is 64 bits" >&5 if eval "test \"`echo '$''{'pgac_cv_type_long_long_int_64'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -7584,7 +7617,7 @@ else echo "configure: warning: 64 bit arithmetic disabled when cross-compiling" 1>&2 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7650: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then pgac_cv_type_long_long_int_64=yes else @@ -7643,7 +7676,7 @@ fi if [ x"$HAVE_LONG_LONG_INT_64" = xyes ] ; then cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:7690: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cat >> confdefs.h <<\EOF #define HAVE_LL_CONSTANTS 1 @@ -7671,7 +7704,7 @@ fi if [ x"$HAVE_LONG_LONG_INT_64" = xyes ] ; then if [ x$SNPRINTF = x ] ; then echo $ac_n "checking whether snprintf handles 'long long int' as %lld""... $ac_c" 1>&6 -echo "configure:7675: checking whether snprintf handles 'long long int' as %lld" >&5 +echo "configure:7708: checking whether snprintf handles 'long long int' as %lld" >&5 if test "$cross_compiling" = yes; then echo "$ac_t""assuming not on target machine" 1>&6 # Force usage of our own snprintf, since we cannot test foreign snprintf @@ -7680,7 +7713,7 @@ echo "configure:7675: checking whether snprintf handles 'long long int' as %lld" else cat > conftest.$ac_ext < typedef long long int int64; @@ -7707,7 +7740,7 @@ main() { exit(! does_int64_snprintf_work()); } EOF -if { (eval echo configure:7711: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7744: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""yes" 1>&6 INT64_FORMAT='"%lld"' @@ -7718,7 +7751,7 @@ else rm -fr conftest* echo "$ac_t""no" 1>&6 echo $ac_n "checking whether snprintf handles 'long long int' as %qd""... $ac_c" 1>&6 -echo "configure:7722: checking whether snprintf handles 'long long int' as %qd" >&5 +echo "configure:7755: checking whether snprintf handles 'long long int' as %qd" >&5 if test "$cross_compiling" = yes; then echo "$ac_t""assuming not on target machine" 1>&6 # Force usage of our own snprintf, since we cannot test foreign snprintf @@ -7727,7 +7760,7 @@ echo "configure:7722: checking whether snprintf handles 'long long int' as %qd" else cat > conftest.$ac_ext < typedef long long int int64; @@ -7754,7 +7787,7 @@ main() { exit(! does_int64_snprintf_work()); } EOF -if { (eval echo configure:7758: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:7791: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then echo "$ac_t""yes" 1>&6 INT64_FORMAT='"%qd"' @@ -7794,12 +7827,12 @@ EOF for ac_func in strtoll strtoq do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7798: checking for $ac_func" >&5 +echo "configure:7831: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7859: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7849,12 +7882,12 @@ done for ac_func in strtoull strtouq do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7853: checking for $ac_func" >&5 +echo "configure:7886: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -7903,12 +7936,12 @@ done echo $ac_n "checking for atexit""... $ac_c" 1>&6 -echo "configure:7907: checking for atexit" >&5 +echo "configure:7940: checking for atexit" >&5 if eval "test \"`echo '$''{'ac_cv_func_atexit'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:7968: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_atexit=yes" else @@ -7954,12 +7987,12 @@ else for ac_func in on_exit do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:7958: checking for $ac_func" >&5 +echo "configure:7991: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8019: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -8015,7 +8048,7 @@ fi echo $ac_n "checking size of unsigned long""... $ac_c" 1>&6 -echo "configure:8019: checking size of unsigned long" >&5 +echo "configure:8052: checking size of unsigned long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_unsigned_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8023,7 +8056,7 @@ else ac_cv_sizeof_unsigned_long=4 else cat > conftest.$ac_ext < main() @@ -8034,7 +8067,7 @@ main() exit(0); } EOF -if { (eval echo configure:8038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_unsigned_long=`cat conftestval` else @@ -8060,7 +8093,7 @@ EOF echo $ac_n "checking alignment of short""... $ac_c" 1>&6 -echo "configure:8064: checking alignment of short" >&5 +echo "configure:8097: checking alignment of short" >&5 if eval "test \"`echo '$''{'pgac_cv_alignof_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8068,7 +8101,7 @@ else pgac_cv_alignof_short='sizeof(short)' else cat > conftest.$ac_ext < struct { char filler; short field; } mystruct; @@ -8080,7 +8113,7 @@ main() exit(0); } EOF -if { (eval echo configure:8084: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then pgac_cv_alignof_short=`cat conftestval` else @@ -8100,7 +8133,7 @@ EOF echo $ac_n "checking alignment of int""... $ac_c" 1>&6 -echo "configure:8104: checking alignment of int" >&5 +echo "configure:8137: checking alignment of int" >&5 if eval "test \"`echo '$''{'pgac_cv_alignof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8108,7 +8141,7 @@ else pgac_cv_alignof_int='sizeof(int)' else cat > conftest.$ac_ext < struct { char filler; int field; } mystruct; @@ -8120,7 +8153,7 @@ main() exit(0); } EOF -if { (eval echo configure:8124: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8157: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then pgac_cv_alignof_int=`cat conftestval` else @@ -8140,7 +8173,7 @@ EOF echo $ac_n "checking alignment of long""... $ac_c" 1>&6 -echo "configure:8144: checking alignment of long" >&5 +echo "configure:8177: checking alignment of long" >&5 if eval "test \"`echo '$''{'pgac_cv_alignof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8148,7 +8181,7 @@ else pgac_cv_alignof_long='sizeof(long)' else cat > conftest.$ac_ext < struct { char filler; long field; } mystruct; @@ -8160,7 +8193,7 @@ main() exit(0); } EOF -if { (eval echo configure:8164: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8197: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then pgac_cv_alignof_long=`cat conftestval` else @@ -8181,7 +8214,7 @@ EOF if [ x"$HAVE_LONG_LONG_INT_64" = xyes ] ; then echo $ac_n "checking alignment of long long int""... $ac_c" 1>&6 -echo "configure:8185: checking alignment of long long int" >&5 +echo "configure:8218: checking alignment of long long int" >&5 if eval "test \"`echo '$''{'pgac_cv_alignof_long_long_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8189,7 +8222,7 @@ else pgac_cv_alignof_long_long_int='sizeof(long long int)' else cat > conftest.$ac_ext < struct { char filler; long long int field; } mystruct; @@ -8201,7 +8234,7 @@ main() exit(0); } EOF -if { (eval echo configure:8205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8238: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then pgac_cv_alignof_long_long_int=`cat conftestval` else @@ -8222,7 +8255,7 @@ EOF fi echo $ac_n "checking alignment of double""... $ac_c" 1>&6 -echo "configure:8226: checking alignment of double" >&5 +echo "configure:8259: checking alignment of double" >&5 if eval "test \"`echo '$''{'pgac_cv_alignof_double'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8230,7 +8263,7 @@ else pgac_cv_alignof_double='sizeof(double)' else cat > conftest.$ac_ext < struct { char filler; double field; } mystruct; @@ -8242,7 +8275,7 @@ main() exit(0); } EOF -if { (eval echo configure:8246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:8279: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then pgac_cv_alignof_double=`cat conftestval` else @@ -8280,12 +8313,12 @@ EOF echo $ac_n "checking for POSIX signal interface""... $ac_c" 1>&6 -echo "configure:8284: checking for POSIX signal interface" >&5 +echo "configure:8317: checking for POSIX signal interface" >&5 if eval "test \"`echo '$''{'pgac_cv_func_posix_signals'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < @@ -8296,7 +8329,7 @@ act.sa_flags = SA_RESTART; sigaction(0, &act, &oact); ; return 0; } EOF -if { (eval echo configure:8300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:8333: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* pgac_cv_func_posix_signals=yes else @@ -8326,7 +8359,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:8330: checking for $ac_word" >&5 +echo "configure:8363: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_TCLSH'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8362,7 +8395,7 @@ test -n "$TCLSH" && break done echo $ac_n "checking for tclConfig.sh""... $ac_c" 1>&6 -echo "configure:8366: checking for tclConfig.sh" >&5 +echo "configure:8399: checking for tclConfig.sh" >&5 # Let user override test if test -z "$TCL_CONFIG_SH"; then pgac_test_dirs="$with_tclconfig" @@ -8395,7 +8428,7 @@ fi # Check for Tk configuration script tkConfig.sh if test "$with_tk" = yes; then echo $ac_n "checking for tkConfig.sh""... $ac_c" 1>&6 -echo "configure:8399: checking for tkConfig.sh" >&5 +echo "configure:8432: checking for tkConfig.sh" >&5 # Let user override test if test -z "$TK_CONFIG_SH"; then pgac_test_dirs="$with_tkconfig $with_tclconfig" @@ -8434,7 +8467,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:8438: checking for $ac_word" >&5 +echo "configure:8471: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_NSGMLS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8470,7 +8503,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:8474: checking for $ac_word" >&5 +echo "configure:8507: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_JADE'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8501,7 +8534,7 @@ done echo $ac_n "checking for DocBook V3.1""... $ac_c" 1>&6 -echo "configure:8505: checking for DocBook V3.1" >&5 +echo "configure:8538: checking for DocBook V3.1" >&5 if eval "test \"`echo '$''{'pgac_cv_check_docbook'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8534,7 +8567,7 @@ have_docbook=$pgac_cv_check_docbook echo $ac_n "checking for DocBook stylesheets""... $ac_c" 1>&6 -echo "configure:8538: checking for DocBook stylesheets" >&5 +echo "configure:8571: checking for DocBook stylesheets" >&5 if eval "test \"`echo '$''{'pgac_cv_path_stylesheets'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -8573,7 +8606,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:8577: checking for $ac_word" >&5 +echo "configure:8610: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_SGMLSPL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else diff --git a/configure.in b/configure.in index c572a5fc28..8fd4d2e74d 100644 --- a/configure.in +++ b/configure.in @@ -985,6 +985,15 @@ if test x"$pgac_cv_var_int_optreset" = x"yes"; then AC_DEFINE(HAVE_INT_OPTRESET, 1) fi +AC_CACHE_CHECK([for __getopt_initialized], pgac_cv_var_int___getopt_initialized, +[AC_TRY_LINK([#include ], + [extern int __getopt_initialized; __getopt_initialized = 1;], + [pgac_cv_var_int___getopt_initialized=yes], + [pgac_cv_var_int___getopt_initialized=no])]) +if test x"$pgac_cv_var_int___getopt_initialized" = x"yes"; then + AC_DEFINE(HAVE_INT___GETOPT_INITIALIZED, 1) +fi + # This test makes sure that run tests work at all. Sometimes a shared # library is found by the linker, but the runtime linker can't find it. diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 635880136c..c8f703880d 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.248 2001/10/19 18:19:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.249 2001/10/19 20:47:09 tgl Exp $ * * NOTES * @@ -228,6 +228,9 @@ extern int optind, #ifdef HAVE_INT_OPTRESET extern int optreset; #endif +#ifdef HAVE_INT___GETOPT_INITIALIZED +extern int __getopt_initialized; +#endif /* * postmaster.c - function prototypes @@ -355,7 +358,6 @@ PostmasterMain(int argc, char *argv[]) } } - /* * for security, no dir or file created can be group or other * accessible @@ -422,12 +424,13 @@ PostmasterMain(int argc, char *argv[]) } /* - * Non-option switch arguments don't exist. + * Postmaster accepts no non-option switch arguments. */ if (optind < argc) { postmaster_error("invalid argument -- %s", argv[optind]); - fprintf(stderr, gettext("Try '%s --help' for more information.\n"), progname); + fprintf(stderr, gettext("Try '%s --help' for more information.\n"), + progname); ExitPostmaster(1); } @@ -438,10 +441,15 @@ PostmasterMain(int argc, char *argv[]) IgnoreSystemIndexes(false); - optind = 1; /* start over (should be redundant here) */ + /* reset getopt(3) to rescan arguments */ + optind = 1; #ifdef HAVE_INT_OPTRESET - optreset = 1; + optreset = 1; /* some systems need this */ #endif +#ifdef HAVE_INT___GETOPT_INITIALIZED + __getopt_initialized = 0; /* glibc needs this */ +#endif + while ((opt = getopt(argc, argv, "A:a:B:b:c:D:d:Fh:ik:lm:MN:no:p:Ss-:")) != EOF) { switch (opt) @@ -584,6 +592,20 @@ PostmasterMain(int argc, char *argv[]) ExitPostmaster(1); } + /* + * Now that we are done processing the postmaster arguments, + * reset getopt(3) library so that it will work correctly in + * subprocesses. + */ + optind = 1; +#ifdef HAVE_INT_OPTRESET + optreset = 1; /* some systems need this */ +#endif +#ifdef HAVE_INT___GETOPT_INITIALIZED + __getopt_initialized = 0; /* glibc needs this */ +#endif + + /* For debugging: display postmaster environment */ if (DebugLvl > 2) { extern char **environ; @@ -2179,11 +2201,6 @@ DoBackend(Port *port) av[ac] = (char *) NULL; - optind = 1; /* reset getopt(3) for subprocess */ -#ifdef HAVE_INT_OPTRESET - optreset = 1; -#endif - /* * Release postmaster's working memory context so that backend can * recycle the space. Note this does not trash *MyProcPort, because @@ -2473,11 +2490,6 @@ SSDataBase(int xlop) av[ac] = (char *) NULL; - optind = 1; /* reset getopt(3) for subprocess */ -#ifdef HAVE_INT_OPTRESET - optreset = 1; -#endif - BootstrapMain(ac, av); ExitPostmaster(0); } diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index ecb16686b3..dea35d611c 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -8,7 +8,7 @@ * or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your * changes will be overwritten the next time you run configure. * - * $Id: pg_config.h.in,v 1.9 2001/10/13 04:23:50 momjian Exp $ + * $Id: pg_config.h.in,v 1.10 2001/10/19 20:47:09 tgl Exp $ */ #ifndef PG_CONFIG_H @@ -667,6 +667,9 @@ extern int fdatasync(int fildes); /* Define if you have the optreset variable */ #undef HAVE_INT_OPTRESET +/* Define if you have the __getopt_initialized variable */ +#undef HAVE_INT___GETOPT_INITIALIZED + /* Define if you have strtoll() */ #undef HAVE_STRTOLL