Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^5: Win32API::File not setting HANDLE_FLAG_PROTECT_FROM_CLOSE (wrong layer)

by tye (Cardinal)
on Dec 05, 2012 at 14:47 UTC ( #1007300=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Win32API::File not setting HANDLE_FLAG_PROTECT_FROM_CLOSE (sources)
in thread Win32API::File not setting HANDLE_FLAG_PROTECT_FROM_CLOSE

The flags are on the OsFHandle and yet you are trying to share the Unixish 'fd'. Try $ENV{myosh} = $os_handle; instead and then open an fd and fh for that in the spawned process (via OsFHandleOpen).

That's how I've done this successfully before.

- tye        


Comment on Re^5: Win32API::File not setting HANDLE_FLAG_PROTECT_FROM_CLOSE (wrong layer)
Download Code
Re^6: Win32API::File not setting HANDLE_FLAG_PROTECT_FROM_CLOSE (wrong layer)
by Yary (Monk) on Dec 05, 2012 at 16:14 UTC
    That works. Adding $ENV{myosh} = $os_handle; to the caller (also removing SetHandleInformation, it isn't needed) and rewriting print_to_3.pl as
    use Win32API::File qw(OsFHandleOpen); OsFHandleOpen(\*OUT,$ENV{myosh},"w"); $x=print OUT "***\nHere is data to OsH $ENV{myosh}\n***\n"; warn "print=$x ($!)\n" unless $x;
    works... Alas the "real" code I am dealing with that "print_to_3.pl" replaces is Unix-y C code. I have already made it use STDERR instead of its own stream, which is working well enough- if there's an error message then the stream is no good anyway, and in the usual case it's easier to manipulate STDERR .

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007300]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (14)
As of 2015-07-02 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (31 votes), past polls