foreach my $md (@chk_mds) { #@chk_mds is a list of the unique identifiers (I.e SrvA, SrvB, SrvC etc) #Read What Kind of Process to Start. if (!&Spawn($md)) { &Update_Log("Problems Spawning $proc[0] Process for $md"); } sleep(1); } #Re-Spawn the broken Process sub Spawn { my $rc = 0; my $md = shift; my $result = Win32::Process::Create( $ProcessObj, "$xcall_path/bin/application.exe", "application.exe $md", 1, #Inherit Handles. NORMAL_PRIORITY_CLASS, ".") or &Update_Log("DEBUG - Cannot Launch the X-$proc process: $!"); if ($result) { my $pid = $ProcessObj->GetProcessID(); $proclst{$md} = $pid; push (@pids, $pid); &Update_Log("\@pids = @pids"); &Update_Log("Launching Call Logger Process for $md with PID - $proclst{$md}"); $rc = $pid; } else { &Update_Log("Process for $md NOT successfully Created:" . Win32::FormatMessage(GetLastError())); } return($rc); } #Update Log file sub Update_Log { my ($ss, $mm, $hh, $d, $mon, $yr) = localtime(); my $date = sprintf("%02d-%02d-%04d", $mon+1, $d, $yr+1900); my $time = sprintf("%02d:%02d:%02d", $hh, $mm, $ss); #Specify the Logfile Name my $logfile = "$xcall_path/log/X-CallServer$date.log"; if (open( LOG, ">>$logfile" ) ) { my $TempSelect = select( LOG ); $| = 1; select( $TempSelect ); if (! $_[0]) { return (0); } print LOG "$time - $_[0]"; } else { &Event(EVENTLOG_ERROR_TYPE, "X-CallServer Could Not Open Logfile $logfile: $!"); exit(5); } close(LOG); return(1); }