| 258 | | $job->spawn(undef, "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"" . $args{'url'}); |
|---|
| 259 | | |
|---|
| 260 | | # TODO: check to see if spawn fails. |
|---|
| | 258 | #$job->spawn(undef, "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"" . $args{'url'}); |
|---|
| | 259 | my $processExec = getVar(name => "process_exec"); |
|---|
| | 260 | my $processName = getVar(name => "process_name"); |
|---|
| | 261 | my $status = $job->spawn($processExec, $processName . " " . $args{'url'}); |
|---|
| | 262 | |
|---|
| | 263 | # Sanity check. |
|---|
| | 264 | if (!defined($status)) { |
|---|
| | 265 | $LOG->error("Error: Unable to spawn a new browser - " . $^E . "."); |
|---|
| | 266 | Carp::croak "Error: Unable to spawn a new browser - " . $^E . ".\n"; |
|---|
| | 267 | } |
|---|
| | 273 | $status = $job->status(); |
|---|
| | 274 | |
|---|
| | 275 | # Sanity check. |
|---|
| | 276 | if (!defined($status) || |
|---|
| | 277 | !scalar(%{$status})) { |
|---|
| | 278 | $LOG->error("Error: Unable to retrieve job status from spawned process."); |
|---|
| | 279 | Carp::croak "Error: Unable to retrieve job status from spawned process.\n"; |
|---|
| | 280 | } |
|---|
| | 281 | |
|---|
| | 282 | # Figure out the correct Process ID. |
|---|
| | 283 | my @keys = keys(%{$status}); |
|---|
| | 284 | my $processID = pop(@keys); |
|---|
| | 285 | |
|---|
| | 286 | # Sanity checks. |
|---|
| | 287 | if (!defined($processID) || |
|---|
| | 288 | !exists($status->{$processID}->{'exitcode'}) || |
|---|
| | 289 | !defined($status->{$processID}->{'exitcode'})) { |
|---|
| | 290 | $LOG->error("Error: Unable to retrieve job status from spawned process."); |
|---|
| | 291 | Carp::croak "Error: Unable to retrieve job status from spawned process.\n"; |
|---|
| | 292 | } |
|---|
| | 293 | |
|---|
| | 294 | # Check to make sure the exitcode is '293', meaning, that the |
|---|
| | 295 | # application didn't unexpectedly die early. |
|---|
| | 296 | if ($status->{$processID}->{'exitcode'} != 293) { |
|---|
| | 297 | $LOG->warn("'" . $processName . "' process (ID = " . $processID . ") unexpectedly terminated early!"); |
|---|
| | 298 | } |
|---|