cpan-authors / IPC-Run

https://metacpan.org/pod/IPC::Run
Other
21 stars 38 forks source link

IPC::Run::start() breaks tempdir permission on Windows #141

Open iynehz opened 4 years ago

iynehz commented 4 years ago

It can be demoed via a script like below,

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.

My Perl is Strawberry Perl 5.30.1.