gautamparimoo has asked for the wisdom of the Perl Monks concerning the following question:
Hi
I have a perl executable which recurses a filesystem using File::Find now I want to implement a pause and resume functionality such that the exe pauses in current state(or preserves current position) is some key is pressed or some other exe tells it to pause and then resume when key is pressed again or other exe tells to resume:
I thought of two approaches: 1.Remember the current file being recursed in a output file . Now this output file will give the last file traversed if we stop the program and restart it . But I cannot recurse from that file (I can skip all file till that file but that would take a lot of time and would not really be like a pause)to resume the recursion.
2. Maintain a second exe which calls some function to pause the state of the main exe and then resume again through the second exe. But how can I do it?? Please help??
Now I was having a look at Win32::Process and tried the following code ::
use Win32::Process; use Win32; sub ErrorReport { print Win32::FormatMessage( Win32::GetLastError() ); } Win32::Process::Create($ProcessObj, "C:\\Perl\\bin\\perl.exe", "perl CC4.4.pl ", 1, NORMAL_PRIORITY_CLASS, ".")|| die ErrorReport(); $ProcessObj->Suspend(); $ProcessObj->Resume(); #$ProcessObj->Wait(INFINITE);
The above code is Script A and CC4.4.pl is Script B. Questions: $ProcessObj->Suspend() is given at the time of execution how do i arbitarily invoke it at any time? As the script A is running so I cannot tell it to suspend at runtime?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pause and Resume Exe
by BrowserUk (Patriarch) on Feb 27, 2013 at 11:46 UTC | |
by gautamparimoo (Beadle) on Feb 27, 2013 at 11:56 UTC | |
by BrowserUk (Patriarch) on Feb 27, 2013 at 12:10 UTC | |
by gautamparimoo (Beadle) on Feb 28, 2013 at 05:46 UTC | |
by BrowserUk (Patriarch) on Feb 28, 2013 at 12:10 UTC | |
| |
| A reply falls below the community's threshold of quality. You may see it by logging in. |