Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / bin / PerlACE / Process.pm
blob854ad19039df583e2bd63e8aa31f3ac8de94f36f
1 #!/usr/bin/env perl
3 package PerlACE::Process;
5 use strict;
6 use English;
7 use POSIX qw(:time_h);
9 $PerlACE::Process::ExeSubDir = './';
11 sub delay_factor {
12 my($lps) = 128;
13 my($factor) = 1;
15 ## Keep increasing the loops per second until the amount of time
16 ## exceeds the number of clocks per second. The original code
17 ## did not multiply $ticks by 8 but, for faster machines, it doesn't
18 ## seem to return false values. The multiplication is done to minimize
19 ## the amount of time it takes to determine the correct factor.
20 while(($lps <<= 1)) {
21 my($ticks) = clock();
22 for(my $i = $lps; $i >= 0; $i--) {
24 $ticks = clock() - $ticks;
25 if ($ticks * 8 >= CLOCKS_PER_SEC) {
26 $factor = 500000 / (($lps / $ticks) * CLOCKS_PER_SEC);
27 last;
30 return $factor;
33 ### Check for -ExeSubDir commands, store the last one
34 my @new_argv = ();
36 for(my $i = 0; $i <= $#ARGV; ++$i) {
37 if ($ARGV[$i] eq '-ExeSubDir') {
38 if (defined $ARGV[$i + 1]) {
39 $PerlACE::Process::ExeSubDir = $ARGV[++$i].'/';
41 else {
42 print STDERR "You must pass a directory with ExeSubDir\n";
43 exit(1);
46 else {
47 push @new_argv, $ARGV[$i];
50 @ARGV = @new_argv;
52 $PerlACE::Process::WAIT_DELAY_FACTOR = (defined $ENV{'ACE_RUNTEST_DELAY'}) ? $ENV{'ACE_RUNTEST_DELAY'} : 1;
54 # Set the process's target. If there's none, behavior falls back to pre-target
55 # behavior.
56 sub Target($)
58 my $self = shift;
59 $self->{TARGET} = shift;
62 if ($OSNAME eq "MSWin32") {
63 require PerlACE::Process_Win32;
65 elsif ($OSNAME eq "VMS") {
66 require PerlACE::Process_VMS;
68 else {
69 require PerlACE::Process_Unix;