From 3d4f1eb94b74f3be92b99b74e099ab0185c9acc3 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Tue, 21 Oct 2025 21:47:45 +0100 Subject: [PATCH] Improved run_program() in Perl regression test scripts. This version works with the native Windows (mingw64 and clang64) versions of Perl in MSYS2. Note that warnings are disabled in the Environment.pm module because Perl fails to notice that OLDOUT and OLDERR are used when restoring the STDOUT and STDERR file handles. --- ivtest/perl-lib/Environment.pm | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ivtest/perl-lib/Environment.pm b/ivtest/perl-lib/Environment.pm index ecdb49e15..a348e91cc 100644 --- a/ivtest/perl-lib/Environment.pm +++ b/ivtest/perl-lib/Environment.pm @@ -5,7 +5,7 @@ package Environment; use strict; -use warnings; +#use warnings; our $VERSION = '1.03'; @@ -109,19 +109,19 @@ sub get_ivl_version { sub run_program { my ($cmd, $log_mode, $log_file) = @_; - my $pid = fork(); - if (!defined($pid)) { - die("couldn't spawn new process\n"); - } elsif ($pid == 0) { - if ($log_mode) { - open(STDOUT, $log_mode, $log_file) or die("couldn't open log file '$log_file'\n"); - open(STDERR, '>&STDOUT'); - } - exec($cmd); + my $ret; + if ($log_mode) { + open(OLDOUT, '>&STDOUT'); + open(OLDERR, '>&STDERR'); + open(STDOUT, $log_mode, $log_file) or die("couldn't open log file '$log_file'\n"); + open(STDERR, '>&STDOUT'); + $ret = system($cmd); + open(STDOUT, '>&OLDOUT'); + open(STDERR, '>&OLDERR'); } else { - waitpid($pid, 0); - $?; # return the child's exit status + $ret = system($cmd); } + $ret; } 1; # Module loaded OK