Skip to content

Commit c818c25

Browse files
committed
psql: Improve portability of query cancel test
Some shells apparently don't support $PPID, so skip the test in that case.
1 parent 945f395 commit c818c25

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/bin/psql/t/020_cancel.pl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,21 @@
2525

2626
local %ENV = $node->_get_env();
2727

28+
my ($stdin, $stdout, $stderr);
29+
30+
# Test whether shell supports $PPID. It's part of POSIX, but some
31+
# pre-/non-POSIX shells don't support it (e.g., NetBSD, Solaris).
32+
$stdin = "\\! echo \$PPID";
33+
IPC::Run::run(['psql', '-X', '-v', 'ON_ERROR_STOP=1'], '<', \$stdin, '>', \$stdout, '2>', \$stderr);
34+
$stdout =~ /^\d+$/ or skip "shell apparently does not support \$PPID", 2;
35+
2836
local $SIG{ALRM} = sub {
2937
my $psql_pid = TestLib::slurp_file("$tempdir/psql.pid");
3038
kill 'INT', $psql_pid;
3139
};
3240
alarm 1;
3341

34-
my $stdin = "\\! echo \$PPID >$tempdir/psql.pid\nselect pg_sleep(3);";
35-
my ($stdout, $stderr);
42+
$stdin = "\\! echo \$PPID >$tempdir/psql.pid\nselect pg_sleep(3);";
3643
my $result = IPC::Run::run(['psql', '-X', '-v', 'ON_ERROR_STOP=1'], '<', \$stdin, '>', \$stdout, '2>', \$stderr);
3744

3845
ok(!$result, 'query failed as expected');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy