pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Pg Hackers <pgsql-hackers@lists.postgresql.org>
Subject: trivial improvement to system_or_bail
Date: Wed, 30 Jun 2021 11:24:33 -0400
Message-ID: <202106301524.eq5pblzstapj@alvherre.pgsql> (raw)

When PostgresNode::system_or_bail() fails, it's quite opaque as to what
is happening.  This patch improves things by printing some detail, as
suggested in Perl's doc for system().

-- 
Álvaro Herrera                            39°49'30"S 73°17'W
                               https://www.EnterpriseDB.com/

Attachments:

system_or_bail.patch (text/x-diff, 704B) download AuthorDate: Tue Jun 15 12:46:42 2021 -0400 CommitDate: Tue Jun 15 12:46:54 2021 -0400 improve TestLib::system_or_bail reporting of system() failures diff --git a/src/test/perl/TestLib.pm b/src/test/perl/TestLib.pm index 26fbe08d4b..eb49923b42 100644 --- a/src/test/perl/TestLib.pm +++ b/src/test/perl/TestLib.pm @@ -375,7 +375,18 @@ sub system_or_bail { if (system_log(@_) != 0) { - BAIL_OUT("system $_[0] failed"); + if ($? == -1) + { + BAIL_OUT("system $_[0] failed: $!\n"); + } + elsif ($? & 127) + { + BAIL_OUT(sprintf("system $_[0] died with signal %d\n", $? & 127)); + } + else + { + BAIL_OUT(sprintf("system $_[0] exited with value %d\n", $? >> 8)); + } } return; }

view thread (5+ messages)  latest in thread

Message-ID: <202106301524.eq5pblzstapj@alvherre.pgsql>
Permalink:  ../202106301524.eq5pblzstapj@alvherre.pgsql/
Also on:    postgresql.org/message-id/202106301524.eq5pblzstapj@alvherre.pgsql

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: trivial improvement to system_or_bail
  In-Reply-To: <202106301524.eq5pblzstapj@alvherre.pgsql>
  References: <202106301524.eq5pblzstapj@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox