From 11e6137fee946b8e031ffaad536b0b0e8163cab2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:37:32 +0100 Subject: Bug#26686 mysql-test-run.pl aborts when waitpid returns -1 - Add error handling for waitpid returns -1 for "simple run of command" mysql-test/lib/mtr_process.pl: - Add error handling for waitpid returns -1 when a simple command is run. - Add missing return - Add mtr_errors where the program should never come - Remove an else to improve program readability - Change mtr_debug to mtr_warning for "Got EAGAIN from fork()..." --- mysql-test/lib/mtr_process.pl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'mysql-test/lib') diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 9cf013d4e9d..20dca4b6980 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -125,19 +125,18 @@ sub spawn_impl ($$$$$$$$) { { if ( $! == $!{EAGAIN} ) # See "perldoc Errno" { - mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo"); + mtr_warning("Got EAGAIN from fork(), sleep 1 second and redo"); sleep(1); redo FORK; } - else - { - mtr_error("$path ($pid) can't be forked"); - } + + mtr_error("$path ($pid) can't be forked, error: $!"); + } if ( $pid ) { - spawn_parent_impl($pid,$mode,$path); + return spawn_parent_impl($pid,$mode,$path); } else { @@ -202,8 +201,11 @@ sub spawn_impl ($$$$$$$$) { { mtr_child_error("failed to execute \"$path\": $!"); } + mtr_error("Should never come here 1!"); } + mtr_error("Should never come here 2!"); } + mtr_error("Should never come here 3!"); } @@ -216,12 +218,21 @@ sub spawn_parent_impl { { if ( $mode eq 'run' ) { - # Simple run of command, we wait for it to return + # Simple run of command, wait blocking for it to return my $ret_pid= waitpid($pid,0); if ( $ret_pid != $pid ) { - mtr_error("waitpid($pid, 0) returned $ret_pid " . - "when waiting for '$path'"); + # The "simple" waitpid has failed, print debug info + # and try to handle the error + mtr_warning("waitpid($pid, 0) returned $ret_pid " . + "when waiting for '$path', error: '$!'"); + if ( $ret_pid == -1 ) + { + # waitpid returned -1, that would indicate the process + # no longer exist and waitpid couldn't wait for it. + return 1; + } + mtr_error("Error handling failed"); } return mtr_process_exit_status($?); -- cgit v1.2.1 From b813fe94302534c0fce4882892c2c7e94b70aec3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:52:51 +0100 Subject: Bug#26416 mysql-test-run exits with "Hangup" when piped to grep - Thanks to Christian for the patch! mysql-test/lib/mtr_process.pl: Avoid printout of "Hangup" when script exits by using POSIX::kill --- mysql-test/lib/mtr_process.pl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'mysql-test/lib') diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 20dca4b6980..e9e0dcce1b8 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -8,7 +8,7 @@ use Socket; use Errno; use strict; -use POSIX 'WNOHANG'; +use POSIX qw(WNOHANG SIGHUP); sub mtr_run ($$$$$$;$); sub mtr_spawn ($$$$$$;$); @@ -1100,12 +1100,6 @@ sub mtr_kill_processes ($) { # ############################################################################## -# FIXME something is wrong, we sometimes terminate with "Hangup" written -# to tty, and no STDERR output telling us why. - -# FIXME for some reason, setting HUP to 'IGNORE' will cause exit() to -# write out "Hangup", and maybe loose some output. We insert a sleep... - sub mtr_exit ($) { my $code= shift; mtr_timer_stop_all($::glob_timers); @@ -1117,7 +1111,7 @@ sub mtr_exit ($) { # set ourselves as the group leader at startup (with # POSIX::setpgrp(0,0)), but then care must be needed to always do # proper child process cleanup. - kill('HUP', -$$) if !$::glob_win32_perl and $$ == getpgrp(); + POSIX::kill(SIGHUP, -$$) if !$::glob_win32_perl and $$ == getpgrp(); exit($code); } -- cgit v1.2.1