use strict;
use warnings;
use File::Temp;
use IPC::Run qw(start);
my ( $in, $out, $err );
my $h;
{
my $tempdir = File::Temp->newdir;
$h = start( ['foo.bat'], \$in, \$out, \$err );
my $tempfile = "$tempdir/foo";
open( my $f, '>', $tempfile );
print $f "hello\n";
close($f);
}
$h->finish;
where foo.bat could be any executable, I tried
@echo off
echo "hello"
Running this you get
cannot unlink file for C:\Users\xxx\AppData\Local\Temp\hMr0BtHITv\foo: Permission denied at c:/strawberry/perl/lib/File/Temp.pm line 2628.
cannot remove directory for C:/Users/xxx/AppData/Local/Temp/hMr0BtHITv: Directory not empty at c:/strawberry/perl/lib/File/Temp.pm line 2628.
If you don't run IPC::Run at all then it is good. Or if you move "start" to before creating the tempdir it's also good.
It can be demoed via a script like below,
where foo.bat could be any executable, I tried
Running this you get
If you don't run IPC::Run at all then it is good. Or if you move "start" to before creating the tempdir it's also good.
My Perl is Strawberry Perl 5.30.1.