postgres.git / summary / log / commit / refs
commit c818c25f448d0085e1bb2be402463a4b28bc20c4
Author: Peter Eisentraut <peter@eisentraut.org>
Date: Sun Aug 22 16:41:31 2021 +0000
psql: Improve portability of query cancel test
Some shells apparently don't support $PPID, so skip the test in that
case.
src/bin/psql/t/020_cancel.pl | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/bin/psql/t/020_cancel.pl b/src/bin/psql/t/020_cancel.pl
index 60b6d1f5445..7713fff8e44 100644
--- a/src/bin/psql/t/020_cancel.pl
+++ b/src/bin/psql/t/020_cancel.pl
@@ -25,14 +25,21 @@ SKIP: {
local %ENV = $node->_get_env();
+ my ($stdin, $stdout, $stderr);
+
+ # Test whether shell supports $PPID. It's part of POSIX, but some
+ # pre-/non-POSIX shells don't support it (e.g., NetBSD, Solaris).
+ $stdin = "\\! echo \$PPID";
+ IPC::Run::run(['psql', '-X', '-v', 'ON_ERROR_STOP=1'], '<', \$stdin, '>', \$stdout, '2>', \$stderr);
+ $stdout =~ /^\d+$/ or skip "shell apparently does not support \$PPID", 2;
+
local $SIG{ALRM} = sub {
my $psql_pid = TestLib::slurp_file("$tempdir/psql.pid");
kill 'INT', $psql_pid;
};
alarm 1;
- my $stdin = "\\! echo \$PPID >$tempdir/psql.pid\nselect pg_sleep(3);";
- my ($stdout, $stderr);
+ $stdin = "\\! echo \$PPID >$tempdir/psql.pid\nselect pg_sleep(3);";
my $result = IPC::Run::run(['psql', '-X', '-v', 'ON_ERROR_STOP=1'], '<', \$stdin, '>', \$stdout, '2>', \$stderr);
ok(!$result, 'query failed as expected');
[parent: 945f395aeb74]