Yary has asked for the wisdom of the Perl Monks concerning the following question:
I have used Win32API::File to get out of a few tight spots in the last couple years. Alas I have now gotten into a spot that it should help me with, but I am coming up short. I'm unable to set the HANDLE_FLAG_PROTECT_FROM_CLOSE flag and I'm not sure if it is a problem with the module, or with my environment.
Here's sample code:
That prints#!perl -w use strict; use Win32API::File qw(:Func :HANDLE_FLAG_); open my $fh,">&2"; my $os_handle=GetOsFHandle($fh) or die "Can't GetOSFHandle: $^E,\nstop +ped"; GetHandleInformation($os_handle, my $flags); print "flags was=$flags\n"; print "HANDLE_FLAG_PROTECT_FROM_CLOSE=",HANDLE_FLAG_PROTECT_FROM_CLOSE +,"\n"; $flags |= HANDLE_FLAG_INHERIT|HANDLE_FLAG_PROTECT_FROM_CLOSE; print "Trying for flags=$flags\n"; SetHandleInformation($os_handle, $flags, $flags) or die "Can't SetHandleInformation: $^E,\nstopped"; GetHandleInformation($os_handle, my $newflags); print "flags now=$newflags\n";
flags was=1 HANDLE_FLAG_PROTECT_FROM_CLOSE=2 Trying for flags=3 flags now=1It's the last line "flags now=1" that indicates to me that SetHandleInformation isn't actually setting "HANDLE_FLAG_PROTECT_FROM_CLOSE"
perl -v This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail)Any ideas?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32API::File not setting HANDLE_FLAG_PROTECT_FROM_CLOSE (sources)
by tye (Sage) on Nov 29, 2012 at 04:10 UTC | |
by Yary (Pilgrim) on Dec 01, 2012 at 01:23 UTC | |
by tye (Sage) on Dec 01, 2012 at 01:35 UTC | |
by Yary (Pilgrim) on Dec 05, 2012 at 13:20 UTC | |
by tye (Sage) on Dec 05, 2012 at 14:47 UTC | |
|