Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+9-2
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)