Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

open3 generates Windows Command Processor Has Stopped Working

by DanEllison (Scribe)
on Nov 12, 2014 at 23:42 UTC ( [id://1107034]=perlquestion: print w/replies, xml ) Need Help??

DanEllison has asked for the wisdom of the Perl Monks concerning the following question:

I have a scheduler that I have written in Perl and executes its jobs using open3 so that it can capture both outputs seperately. The jobs being executed are also Perl scripts. It runs more than 1500 jobs a day, but in reality, they are primarily only 3 different Perl scripts called with 500 different parameters each. So, the called jobs are well tested.

I've got probably better than a 98% success rate. Occasionally a job executed via the open3 will generate a pop-up window with the error "Windows Command Processor Has Stopped Working". I've put a print at the very end of each of the Perl scripts so I can verify that the job has made it to the exit, and the prints do get captured by the open3. However, the output streams don't close and the waitpid doesn't return until I click on the pop-up window to close it. Then the waitpid returns a non-zero status even though it appears to me that the job has run successfully to completion.

I'm on Windows 8, but this has been occurring since long before that.

Does any one know why I would get this failed Windows Command Processor error on an exit 0? And not that I want to hide the problem, but the scheduler will automatically retry, so is there anyway I could avoid this pop-up on the failure because otherwise it hangs until I click on it?

Replies are listed 'Best First'.
Re: open3 generates Windows Command Processor Has Stopped Working
by BrowserUk (Patriarch) on Nov 13, 2014 at 08:03 UTC

    You may be able to prevent the popup being shown by use SetErrorMode() as described by Corion and tye.


    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.
Re: open3 generates Windows Command Processor Has Stopped Working
by Anonymous Monk on Nov 13, 2014 at 00:13 UTC

    Does any one know why I would get this failed Windows Command Processor error on an exit 0?

    I dont, the MSDN might :)

    Also, it might be related to open3, you might have better luck with Capture::Tiny if its applicable to your application

    And not that I want to hide the problem, but the scheduler will automatically retry, so is there anyway I could avoid this pop-up on the failure because otherwise it hangs until I click on it?

    Yup, Win32API::File::SetErrorMode( 2);

      I've posted on MSDN and answers.microsoft but I'm getting the run around.

      I'm now running with SetErrorMode, but I'm still getting the pop-ups. I assume because it isn't really the perl job thats failing, but that the child perl job that is executed by open3 is getting wrapped in a cmd.exe. Although I don't get an error from the application, there are errors in the event viewer:

      Faulting application name: cmd.exe, version: 6.3.9600.16384, time stam +p: 0x5215e1f2 Faulting module name: dlnashext.dll_unloaded, version: 12.0.9600.16384 +, time stamp: 0x5215eb81 Exception code: 0xc0000005 Fault offset: 0x0000000000011882 Faulting process id: 0x1a5c8 Faulting application start time: 0x01cfff94a6b53f60 Faulting application path: C:\Windows\system32\cmd.exe Faulting module path: dlnashext.dll Report Id: e56a707d-6b87-11e4-826d-48d22452e95d Faulting package full name: Faulting package-relative application ID:

      I'm wondering now if the cmd.exe is being called because I'm simply trying to execute "stats.pl" and it needs to determine what executable can run that file type. Or will open3 always run the child in cmd.exe even if I change the command to "perl %STOCKS%/bin/stats.pl"?

        I suggest that you look at this and read it carefully. (All the way the end!)

        The problem is nothing to do with Perl.


        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.
        Try using 32775 which is maximum bittage according to docs of Win32API::File
        perl -MWin32API::File - die Win32API::File::SEM_FAILCRITICALERRORS() |Win32API::File::SEM_NOALIGNMENTFAULTEXCEPT() |Win32API::File::SEM_NOGPFAULTERRORBOX() |Win32API::File::SEM_NOOPENFILEERRORBOX() __END__ 32775 at - line 1.

      I have the .pl extension registered, and the command I was trying to execute via open3 was simply "stats.pl". Even though Windows was searching the path and finding it successfully, File::which will not find it, so I had to write my own variation. I first fully qualified the program name, and then determining that it was a perl script, I preceded it with an explicit call to perl. Then open3 did not need to run it in the command processor and I was able to make a full run without failures.

      I'll continue to complain in the windows forums about the command processor failures.

Re: open3 generates Windows Command Processor Has Stopped Working
by james28909 (Deacon) on Nov 13, 2014 at 03:12 UTC
    you could use win32::GuiTest to get the window name, and then check if its open, then if its not, relaunch the program. tho i dunno if this would work for your situation, it was the first thing that popped into my mind
Re: open3 generates Windows Command Processor Has Stopped Working
by Anonymous Monk on Feb 09, 2017 at 00:21 UTC
    Open3.capture3 doesn't work well with stdin_data. no input is passed to the actual cmd giving an impression of hang while its waiting for input. seems to be a bug in implementation.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-03-29 01:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found