Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^8: Win32: Setting a layer with binmode causes problem with close() on Windows (PerlIO silently fails to close the file)

by BrowserUk (Patriarch)
on Jun 17, 2013 at 13:38 UTC ( [id://1039368]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Win32: Setting a layer with binmode causes problem with close() on Windows (PerlIO silently fails to close the file)
in thread Win32: Setting a layer with binmode causes problem with close() on Windows

system 1,... can be blocking

Please elucidate? (Preferably demonstrate.)


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^9: Win32: Setting a layer with binmode causes problem with close() on Windows (PerlIO silently fails to close the file)
by Anonymous Monk on Jun 17, 2013 at 14:10 UTC

    Please elucidate? (Preferably demonstrate.)

    Its hard (cant test ATM), but it goes like this,
    apache2 on win32 runs tracertfrontend.cgi which does  system 1, logtracertwithipcrun3.pl and redirects,
    except logtracertwithipcrun3.pl blocks tracertfrontend.cgi

    even if longtracertwithipcrun3.pl does another system 1... itself, STDIN/STDOUT/STDERR handles are still inherited (despite 0 flag), and it still blocks tracertfrontend.cgi

    This scenario can work from (cmd.exe) console (no blocking), but not under whatever environment apache sets up (something like without console )

    Proc::Background::Win32 tries to launch without inheriting handles, but it still blocks under apache

    Win32::Process::Create/DETACHED_PROCESS combo seems to keep tracertfrontend.cgi from being blocked under apache

      This scenario can work from (cmd.exe) console (no blocking), but not under whatever environment apache sets up (something like without console )

      The problem is apache -- actually most webservers -- in that they do not forward the output from CGI processes until (all copies of) both STDOUT and STDERR handles have been closed. If you close those before launching your async process via system 1, ..., then it will not cause the server to block. You can also close them (immediately) within the async script or process.

      With respect to Win32::Process, if you set the iflag parameter to false:

      Win32::Process::Create($obj,$appname,$cmdline,$iflags,$cflags,$curdir) Creates a new process. Args: $obj container for process object $appname full path name of executable module $cmdline command line args $iflags flag: inherit calling processes handles or not $cflags flags for creation (see exported vars below) $curdir working dir of new process

      That will also prevent the problem.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

        If you close those before launching your async process via system 1, ..., then it will not cause the server to block.

        :) yes, I'm aware that is common, and I had close ... and it didn't work

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-03-28 11:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found