diff options
author | Peter Eisentraut <peter@eisentraut.org> | 2021-08-22 18:41:31 +0200 |
---|---|---|
committer | Peter Eisentraut <peter@eisentraut.org> | 2021-08-22 18:51:38 +0200 |
commit | c818c25f448d0085e1bb2be402463a4b28bc20c4 (patch) | |
tree | ae0163e4f67932ac9e608be201519b80eb982ab0 /src | |
parent | 945f395aeb74cea77d5239db01357bbcbea80534 (diff) | |
download | postgresql-c818c25f448d0085e1bb2be402463a4b28bc20c4.tar.gz postgresql-c818c25f448d0085e1bb2be402463a4b28bc20c4.zip |
psql: Improve portability of query cancel test
Some shells apparently don't support $PPID, so skip the test in that
case.
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/psql/t/020_cancel.pl | 11 |
1 files 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'); |