~ubuntu-branches/ubuntu/maverick/mysql-5.1/maverick-proposed

« back to all changes in this revision

Viewing changes to mysql-test/lib/My/SafeProcess.pm

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2012-02-22 14:16:05 UTC
  • mto: This revision was merged to the branch mainline in revision 20.
  • Revision ID: package-import@ubuntu.com-20120222141605-nxlu9yzc6attylc2
Tags: upstream-5.1.61
ImportĀ upstreamĀ versionĀ 5.1.61

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- cperl -*-
2
 
# Copyright (C) 2004-2006 MySQL AB
 
2
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
3
3
#
4
 
# This program is free software; you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation; version 2 of the License.
 
4
# This program is free software; you can redistribute it and/or
 
5
# modify it under the terms of the GNU Library General Public
 
6
# License as published by the Free Software Foundation; version 2
 
7
# of the License.
7
8
#
8
9
# This program is distributed in the hope that it will be useful,
9
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
12
# Library General Public License for more details.
12
13
#
13
14
# You should have received a copy of the GNU General Public License
14
15
# along with this program; if not, write to the Free Software
60
61
 
61
62
my %running;
62
63
my $_verbose= 0;
 
64
my $start_exit= 0;
63
65
 
64
66
END {
65
67
  # Kill any children still running
66
68
  for my $proc (values %running){
67
 
    if ( $proc->is_child($$) ){
 
69
    if ( $proc->is_child($$) and ! $start_exit){
68
70
      #print "Killing: $proc\n";
69
71
      if ($proc->wait_one(0)){
70
72
        $proc->kill();
149
151
 
150
152
  push(@safe_args, "--");
151
153
  push(@safe_args, $path); # The program safe_process should execute
 
154
 
 
155
  if ($start_exit) {     # Bypass safe_process instead, start program directly
 
156
    @safe_args= ();
 
157
    $safe_path= $path;
 
158
  }
152
159
  push(@safe_args, @$$args);
153
160
 
154
161
  print "### safe_path: ", $safe_path, " ", join(" ", @safe_args), "\n"
528
535
  }
529
536
}
530
537
 
 
538
#
 
539
# Set global flag to tell all safe_process to exit after starting child
 
540
#
 
541
 
 
542
sub start_exit {
 
543
  $start_exit= 1;
 
544
}
531
545
 
532
546
#
533
547
# Check if any process has exited, but don't wait.