Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: Pause and Resume Exe

by gautamparimoo (Beadle)
on Feb 27, 2013 at 11:56 UTC ( #1020859=note: print w/ replies, xml ) Need Help??


in reply to Re: Pause and Resume Exe
in thread Pause and Resume Exe

But I have to specify in the beginning only when to suspend and resume the exe. Nothing can be given while script is already running


Comment on Re^2: Pause and Resume Exe
Re^3: Pause and Resume Exe
by BrowserUk (Pope) on Feb 27, 2013 at 12:10 UTC
    But I have to specify in the beginning only when to suspend and resume the exe.

    No you don't.

    Script A uses Win32::Process::CreateProcess() to start perl.exe running script B. It gets a process handle back from that call.

    Script B is running asynchronously from Script A. And Script A can call $hproc->Suspend() and $hproc->Resume() whenever it chooses to.


    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.

      @BrowserUK . Plz elaborate how can tell the script A to suspend through script B(I cannot hardcode in script B to suspend for some time as that would be known only at runtime)and then resume again?

        Given count.pl that looks like this:

        C:\test>type count.pl #! perl -slw use strict; use 5.010; say for 1 .. 1e6;

        You can run that script using this script:

        #! perl -slw use strict; use Win32::Process; Win32::Process::Create( my $hProc, '/perl64/bin/perl.exe', 'perl count.pl', 0, 0, '.' ) or die $^E; my $state = 1; while( <STDIN> ) { if( $state ) { $hProc->Suspend(); $state = 0; } else { $hProc->Resume(); $state = 1; } print "\nProcess is ", $state ? 'running' : 'suspended'; }

        And each time you press enter on the command line, count.pl will be suspended or resumed.


        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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2014-07-30 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (235 votes), past polls