~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to mysql-test/lib/mtr_process.pl

  • Committer: msvensson at pilot
  • Date: 2007-04-24 09:11:45 UTC
  • mfrom: (2469.1.106)
  • Revision ID: sp1r-msvensson@pilot.blaudden-20070424091145-10463
Merge pilot.blaudden:/home/msvensson/mysql/my51-m-mysql_upgrade
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
sub mtr_ping_with_timeout($);
39
39
sub mtr_ping_port ($);
40
40
 
41
 
# static in C
42
 
sub spawn_impl ($$$$$$$$);
 
41
# Local function
 
42
sub spawn_impl ($$$$$$$);
43
43
 
44
44
##############################################################################
45
45
#
47
47
#
48
48
##############################################################################
49
49
 
50
 
# This function try to mimic the C version used in "netware/mysql_test_run.c"
51
 
 
52
50
sub mtr_run ($$$$$$;$) {
53
51
  my $path=       shift;
54
52
  my $arg_list_t= shift;
55
53
  my $input=      shift;
56
54
  my $output=     shift;
57
55
  my $error=      shift;
58
 
  my $pid_file=   shift;
 
56
  my $pid_file=   shift; # Not used
59
57
  my $spawn_opts= shift;
60
58
 
61
 
  return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,$pid_file,
 
59
  return spawn_impl($path,$arg_list_t,'run',$input,$output,$error,
62
60
    $spawn_opts);
63
61
}
64
62
 
68
66
  my $input=      shift;
69
67
  my $output=     shift;
70
68
  my $error=      shift;
71
 
  my $pid_file=   shift;
 
69
  my $pid_file=   shift; # Not used
72
70
  my $spawn_opts= shift;
73
71
 
74
 
  return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,$pid_file,
 
72
  return spawn_impl($path,$arg_list_t,'test',$input,$output,$error,
75
73
    $spawn_opts);
76
74
}
77
75
 
81
79
  my $input=      shift;
82
80
  my $output=     shift;
83
81
  my $error=      shift;
84
 
  my $pid_file=   shift;
 
82
  my $pid_file=   shift; # Not used
85
83
  my $spawn_opts= shift;
86
84
 
87
 
  return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,$pid_file,
 
85
  return spawn_impl($path,$arg_list_t,'spawn',$input,$output,$error,
88
86
    $spawn_opts);
89
87
}
90
88
 
91
89
 
92
 
##############################################################################
93
 
#
94
 
#  If $join is set, we return the error code, else we return the PID
95
 
#
96
 
##############################################################################
97
90
 
98
 
sub spawn_impl ($$$$$$$$) {
 
91
sub spawn_impl ($$$$$$$) {
99
92
  my $path=       shift;
100
93
  my $arg_list_t= shift;
101
94
  my $mode=       shift;
102
95
  my $input=      shift;
103
96
  my $output=     shift;
104
97
  my $error=      shift;
105
 
  my $pid_file=   shift;                 # FIXME
106
98
  my $spawn_opts= shift;
107
99
 
108
100
  if ( $::opt_script_debug )
155
147
    else
156
148
    {
157
149
      # Child, redirect output and exec
158
 
      # FIXME I tried POSIX::setsid() here to detach and, I hoped,
159
 
      # avoid zombies. But everything went wild, somehow the parent
160
 
      # became a deamon as well, and was hard to kill ;-)
161
 
      # Need to catch SIGCHLD and do waitpid or something instead......
162
150
 
163
151
      $SIG{INT}= 'DEFAULT';         # Parent do some stuff, we don't
164
152
 
196
184
        }
197
185
        else
198
186
        {
199
 
          if ( ! open(STDERR,$log_file_open_mode,$error) )
 
187
          if ( $::glob_win32_perl )
 
188
          {
 
189
            # Don't redirect stdout on ActiveState perl since this is
 
190
            # just another thread in the same process.
 
191
            # Should be fixed so that the thread that is created with fork
 
192
            # executes the exe in another process and wait's for it to return.
 
193
            # In the meanwhile, we get all the output from mysqld's to screen
 
194
          }
 
195
          elsif ( ! open(STDERR,$log_file_open_mode,$error) )
200
196
          {
201
197
            mtr_child_error("can't redirect STDERR to \"$error\": $!");
202
198
          }
259
255
      # We do blocking waitpid() until we get the return from the
260
256
      # "mysqltest" call. But if a mysqld process dies that we
261
257
      # started, we take this as an error, and kill mysqltest.
262
 
      #
263
 
      # FIXME is this as it should be? Can't mysqld terminate
264
 
      # normally from running a test case?
 
258
 
265
259
 
266
260
      my $exit_value= -1;
267
261
      my $saved_exit_value;
450
444
 
451
445
  # We scan the "var/run/" directory for other process id's to kill
452
446
 
453
 
  # FIXME $path_run_dir or something
454
447
  my $rundir= "$::opt_vardir/run";
455
448
 
456
449
  mtr_debug("Processing PID files in directory '$rundir'...");
1106
1099
 
1107
1100
  foreach my $pid (@$pids)
1108
1101
  {
 
1102
 
 
1103
    if ($pid <= 0)
 
1104
    {
 
1105
      mtr_warning("Trying to kill illegal pid: $pid");
 
1106
      next;
 
1107
    }
 
1108
 
1109
1109
    foreach my $sig (15, 9)
1110
1110
    {
1111
1111
      last if mtr_im_kill_process([ $pid ], $sig, 10, 1);