From e812323792ff6fb59237c2929d6ef2c49c7fa6ba Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 20 Mar 2021 00:02:55 -0500 Subject: [PATCH] Replace Win32::Job with Win32::Process GitHub Actions builders won't let us use Win32::Job --- src/tools/makeTestfile.pl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 9afb24e73..34327741e 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -82,7 +82,8 @@ if ($^O eq 'MSWin32') { ######################################## Code for Windows run-hosts print $OUT <<__WIN32__; -use Win32::Job; +use Win32::Process; +use Win32; BEGIN { # Ensure that Windows interactive error handling is disabled. @@ -104,19 +105,20 @@ BEGIN { SetErrorMode(0x8001) unless \$@; } -my \$job = Win32::Job->new; -die "\$tool: Can't create Win32::Job: \$^E\\n" - unless \$job; -my \$pid = \$job->spawn(undef, '$exec'); -die "\$tool: Can't spawn Process '$exec': \$^E\\n" - unless defined(\$pid); - -if (! \$job->run(\$timeout)) { +my \$proc; +if (! Win32::Process::Create(\$proc, abs_path('$exec'), + '$exec', 1, NORMAL_PRIORITY_CLASS, '.')) { + my \$err = Win32::FormatMessage(Win32::GetLastError()); + die "\$tool: Can't create Process for '$exec': \$err\\n"; +} +if (! \$proc->Wait(1000 * \$timeout)) { + \$proc->Kill(1); print "\\n#### Test stopped by \$tool after \$timeout seconds\\n"; die "\$tool: Timed out '$exec' after \$timeout seconds\\n"; } -my \$status = \$job->status(); -exit \$status->{\$pid}->{exitcode}; +my \$status; +\$proc->GetExitCode(\$status); +exit \$status; __WIN32__ }