I've written a program specifically to keep batches of X processes running concurrently. My company uses this program to automate long-running tasks and keep our servers running as many at a time as possible without overrunning the system. To do this, my perl script periodically checks the status of its child processes (kicked off with a call to open()) using the waitpid() function.
This works like a charm in the Linux world but doesn't perform as expected in the Windows world. The code I think is the problem is the following:
sub check_for_completed_processes
{
my @completed;
my @temp;
# print "Checking for completed procs...\n";
while(my $running = pop @running)
{
if(waitpid($running -> {process_id} ,&WNOHANG))
{
$running -> {end_time} = timestamp();
# print "Finished. \n";
push @completed, $running;
print "Process completed: " . $running -> {process} . "\n";
print "Started at: " . $running -> {start_time} . "\n";
print "End time: " . $running -> {end_time} . "\n";
}
else
{
push @temp, $running;
}
}
@running = @temp;
return @completed;
+
}
This is being run on Windows Server 2003.
Is there a way in the Windows world to do a non-blocking waitpid() call or equivalent?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.