in reply to Re: Multithreaded script keeps files locked when reading output from multiple processes on Windows
in thread Multithreaded script keeps files locked when reading output from multiple processes on Windows
Thanks for your explanation. Was able to work around this by opening files with the FILE_SHARE_DELETE permission as you using Win32API::File and it does seem to do the trick. Replaced the thread code with:
my $tid = threads->tid; my $fn = "file" . $tid; my $winFileHandle = createFile( $fn, "w", "d" ) or die "$!/$^E"; OsFHandleOpen(*OUTPUT, $winFileHandle, "w") or die "$!/$^E"; my $pid = open(my $pipe, "-|", "perl test.pl"); print OUTPUT $_ while(<$pipe>); close(OUTPUT); close($pipe); CloseHandle($winFileHandle);
I do however have another question, well more of a clarification. So in my actual usage, I am using a threadpool and a Thread::Queue and not starting/joining threads after one another. But, I'm just making sure I understand correctly, this does not matter because if I have for example:
Thanks for the help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Multithreaded script keeps files locked when reading output from multiple processes on Windows
by BrowserUk (Patriarch) on Jan 14, 2014 at 09:49 UTC | |
by rmahin (Scribe) on Jan 14, 2014 at 20:40 UTC | |
|
Re^3: Multithreaded script keeps files locked when reading output from multiple processes on Windows
by rmahin (Scribe) on Jan 13, 2014 at 23:29 UTC |