Codebase list libcapture-tiny-perl / 26f46c9
Stop closing Win32 tee pipes with CloseHandle This commit uses regular perl `close` to avoid a double close problem. Previously, Capture::Tiny closed the OS handle with `CloseHandle` but then the perl auto-close tried to close again and triggered a bad file descriptor warning. Fixes issue #26. David Golden 9 years ago
2 changed file(s) with 9 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
00 Revision history for Capture-Tiny
11
22 {{$NEXT}}
3
4 Fixed:
5
6 - Fix double filehandle close error with tee on Windows
7 (which started warning during the perl 5.21.x series,
8 causing tests to fail)
39
410 0.28 2015-02-11 06:39:51-05:00 America/New_York
511
209209 # execute @cmd as a separate process
210210 if ( $IS_WIN32 ) {
211211 local $@;
212 eval "use Win32API::File qw/CloseHandle GetOsFHandle SetHandleInformation fileLastError HANDLE_FLAG_INHERIT INVALID_HANDLE_VALUE/ ";
212 eval "use Win32API::File qw/GetOsFHandle SetHandleInformation fileLastError HANDLE_FLAG_INHERIT INVALID_HANDLE_VALUE/ ";
213213 # _debug( "# Win32API::File loaded\n") unless $@;
214214 my $os_fhandle = GetOsFHandle( $stash->{tee}{$which} );
215215 # _debug( "# Couldn't get OS handle: " . fileLastError() . "\n") if ! defined $os_fhandle || $os_fhandle == INVALID_HANDLE_VALUE();
263263 sub _kill_tees {
264264 my ($stash) = @_;
265265 if ( $IS_WIN32 ) {
266 # _debug( "# closing handles with CloseHandle\n");
267 CloseHandle( GetOsFHandle($_) ) for values %{ $stash->{tee} };
266 # _debug( "# closing handles\n");
267 close($_) for values %{ $stash->{tee} };
268268 # _debug( "# waiting for subprocesses to finish\n");
269269 my $start = time;
270270 1 until wait == -1 || (time - $start > 30);