Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Win32 limit to number of calls to system()?

by BrowserUk (Patriarch)
on Sep 13, 2011 at 08:19 UTC ( [id://925642]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Win32 limit to number of calls to system()?
in thread Win32 limit to number of calls to system()?

Either of these will work:

  1. Use a synchronous system and the start command. This will synchronously run a copy of cmd.exe to run the start command, and it starts the program asynchronously.

    As cmd.exe returns immediately and the synchronous system gathers its exit code, it avoids the accumulation of zombies and the WaitForMultipleObjects() problem:

    for ( 1 .. 100 ) { print "spawning job $_"; system 'start \\Windows\\system32\\notepad.exe'; my $wid = WaitWindow( 'Notepad', 1 ); SetForegroundWindow( $wid ); SendKeys( '%{F4}' ); }
  2. Use the asynchronous system and obtain the pid of the started instance from the returned value.

    Use waitpid to gather the exit code thus avoiding the accumulation of the zombies:

    for ( 1 .. 100 ) { print "spawning job $_"; my $pid = system 1, '/Windows/system32/notepad.exe'; my $wid = WaitWindow( 'Notepad', 1 ); SetForegroundWindow( $wid ); SendKeys( '%{F4}' ); waitpid $pid, 1; }

Finally, 'Simpo PDF to Text' has a 'batch mode' which would be possible -- if awkward -- to drive programmically, but it might be substantially more efficient.

I guess you've already looked at command line driven alternatives?


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^4: Win32 limit to number of calls to system()?
by Limbic~Region (Chancellor) on Sep 13, 2011 at 17:10 UTC
    BrowserUk,
    Finally, 'Simpo PDF to Text' has a 'batch mode' which would be possible

    That is one of the reasons I purchased it. Unfortunately, it is 'batch mode' through the UI and not command line. For my purposes, I need to make a decision after conversion before the next file that does not easily allow me to use the batch mode.

    I guess you've already looked at command line driven alternatives?

    Nothing I looked at did as good a job as Simpo's tool on the particular PDFs I was using. I have used a multitude of OCR tools in the past but I need to keep structure as well as text and it was the best I found for this particular data set.

    Cheers - L~R

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2024-04-24 12:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found