mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
psql: Improve portability of query cancel test
Some shells apparently don't support $PPID, so skip the test in that case.
This commit is contained in:
@ -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');
|
||||
|
Reference in New Issue
Block a user