Howdy peeps, this was originally going to be a private email to module author tye, but alas the address in my copy of Win32API::File is outdated. And perhaps the wider Perl community can help/learn from this.
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:
#!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";
That prints
flags was=1
HANDLE_FLAG_PROTECT_FROM_CLOSE=2
Trying for flags=3
flags now=1
It'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?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|