My new OpenLDAP test case has been breaking each MSVC buildfarm member. Most MinGW members are fine, though the 9.0 and 9.1 narwhal members broke. (Newer narwhal members have been broken long-term.) The MSVC build system has a mundane inability to handle a Makefile construct I used; the first attached patch fixes that. With that fixed, though, the test case reveals a departure from POSIX in pgkill(), our emulation of kill(2) for Windows. A pgkill() call falling very close in time to process exit can easily give ERROR_BROKEN_PIPE, and I at least once observed it give ERROR_BAD_PIPE. pgkill() translates those codes to EINVAL. Only a buggy POSIX program will ever see EINVAL from kill(2). This situation is just like signalling a zombie, and POSIX kill(2) returns zero for zombies. Let's do that, as attached.
I'm inclined to back-patch this, although a quick scan didn't turn up any code having bugs today as a result. The change will affect occasional error messages. (An alternative is to change the test case code in the back branches to treat EINVAL like success.) On my systems, MSVC builds get ERROR_BROKEN_PIPE far more easily than MinGW builds. In MinGW, I ran "make -C contrib/dblink check" many times without ever hitting the error, but "vcregress contribcheck" hit it over 99% of the time. I don't have a theory to explain that. Thanks, nm -- Noah Misch EnterpriseDB http://www.enterprisedb.com
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index 39698ee..a9e95cd 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -331,9 +331,13 @@ sub fetchRegressOpts if ($m =~ /^\s*REGRESS_OPTS\s*=(.*)/m) { - # ignore options that use makefile variables - can't handle those - # ignore anything that isn't an option staring with -- - @opts = grep { $_ !~ /\$\(/ && $_ =~ /^--/ } split(/\s+/, $1); + # Substitute known Makefile variables, then ignore options that retain + # an unhandled variable reference. Ignore anything that isn't an + # option staring with "--". + @opts = grep { + s/\Q$(top_builddir)\E/\"$topdir\"/; + $_ !~ /\$\(/ && $_ =~ /^--/ + } split(/\s+/, $1); } if ($m =~ /^\s*ENCODING\s*=\s*(\S+)/m) {
diff --git a/src/port/kill.c b/src/port/kill.c index 5a7d483..b33283e 100644 --- a/src/port/kill.c +++ b/src/port/kill.c @@ -70,13 +70,28 @@ pgkill(int pid, int sig) return 0; } - if (GetLastError() == ERROR_FILE_NOT_FOUND) - errno = ESRCH; - else if (GetLastError() == ERROR_ACCESS_DENIED) - errno = EPERM; - else - errno = EINVAL; - return -1; + switch (GetLastError()) + { + case ERROR_BROKEN_PIPE: + case ERROR_BAD_PIPE: + + /* + * These arise transiently as a process is exiting. Treat them + * like POSIX treats a zombie process, reporting success. + */ + return 0; + + case ERROR_FILE_NOT_FOUND: + /* pipe fully gone, so treat the process as gone */ + errno = ESRCH; + return -1; + case ERROR_ACCESS_DENIED: + errno = EPERM; + return -1; + default: + errno = EINVAL; /* unexpected */ + return -1; + } } #endif
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers