Commit 253be36c authored by Sergey Vojtovich's avatar Sergey Vojtovich

MDEV-7376 - Removal of the tool "mysql_zap"

parent 0b5e975c
......@@ -39,7 +39,6 @@ scripts/mysql_fix_extensions$
scripts/mysql_install_db$
scripts/mysql_secure_installation$
scripts/mysql_setpermission$
scripts/mysql_zap$
scripts/mysqlaccess$
scripts/mysqld_multi$
scripts/mysqld_safe$
......
......@@ -41,7 +41,6 @@ usr/bin/mysql_secure_installation
usr/bin/mysql_setpermission
usr/bin/mysql_tzinfo_to_sql
usr/bin/mysql_upgrade
usr/bin/mysql_zap
usr/bin/mysqlbinlog
usr/bin/mysqld_multi
usr/bin/mysqld_safe
......@@ -73,7 +72,6 @@ usr/share/man/man1/mysql_install_db.1
usr/share/man/man1/mysql_secure_installation.1
usr/share/man/man1/mysql_setpermission.1
usr/share/man/man1/mysql_upgrade.1
usr/share/man/man1/mysql_zap.1
usr/share/man/man1/perror.1
usr/share/man/man1/replace.1
usr/share/man/man1/resolveip.1
......
......@@ -19,7 +19,7 @@ SET(MAN1_SERVER innochecksum.1 my_print_defaults.1 myisam_ftdump.1 myisamchk.1
mysql_convert_table_format.1 mysql_fix_extensions.1
mysql_install_db.1
mysql_secure_installation.1 mysql_setpermission.1
mysql_tzinfo_to_sql.1 mysql_upgrade.1 mysql_zap.1
mysql_tzinfo_to_sql.1 mysql_upgrade.1
mysqld_multi.1 mysqld_safe.1 mysqldumpslow.1 mysqlhotcopy.1
mysqltest.1 perror.1 replace.1 resolve_stack_dump.1
resolveip.1)
......
'\" t
.\"
.TH "\FBMYSQL_ZAP\FR" "1" "04/08/2015" "MariaDB 10\&.0" "MariaDB Database System"
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.\" mysql_zap
.SH "NAME"
mysql_zap \- kill processes that match a pattern
.SH "SYNOPSIS"
.HP \w'\fBmysql_zap\ [\-\fR\fB\fIsignal\fR\fR\fB]\ [\-?Ift]\ \fR\fB\fIpattern\fR\fR\ 'u
\fBmysql_zap [\-\fR\fB\fIsignal\fR\fR\fB] [\-?Ift] \fR\fB\fIpattern\fR\fR
.SH "DESCRIPTION"
.PP
\fBmysql_zap\fR
kills processes that match a pattern\&. It uses the
\fBps\fR
command and Unix signals, so it runs on Unix and Unix\-like systems\&.
.PP
Invoke
\fBmysql_zap\fR
like this:
.sp
.if n \{\
.RS 4
.\}
.nf
shell> \fBmysql_zap [\-\fR\fB\fIsignal\fR\fR\fB] [\-?Ift] \fR\fB\fIpattern\fR\fR
.fi
.if n \{\
.RE
.\}
.PP
A process matches if its output line from the
\fBps\fR
command contains the pattern\&. By default,
\fBmysql_zap\fR
asks for confirmation for each process\&. Respond
y
to kill the process, or
q
to exit
\fBmysql_zap\fR\&. For any other response,
\fBmysql_zap\fR
does not attempt to kill the process\&.
.PP
If the
\fB\-\fR\fB\fIsignal\fR\fR
option is given, it specifies the name or number of the signal to send to each process\&. Otherwise,
\fBmysql_zap\fR
tries first with
TERM
(signal 15) and then with
KILL
(signal 9)\&.
.PP
\fBmysql_zap\fR
supports the following additional options:
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-\-help\fR,
\fB\-?\fR,
\fB\-I\fR
.sp
Display a help message and exit\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-f\fR
.sp
Force mode\&.
\fBmysql_zap\fR
attempts to kill each process without confirmation\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fB\-t\fR
.sp
Test mode\&. Display information about each process but do not kill it\&.
.RE
.SH "COPYRIGHT"
.br
.PP
Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc., 2010-2015 MariaDB Foundation
.PP
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
.PP
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
.PP
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see http://www.gnu.org/licenses/.
.sp
.SH "SEE ALSO"
For more information, please refer to the MariaDB Knowledge Base, available online at https://mariadb.com/kb/
.SH AUTHOR
MariaDB Foundation (http://www.mariadb.org/).
......@@ -254,7 +254,6 @@ ELSE()
mysql_fix_extensions
mysql_setpermission
mysql_secure_installation
mysql_zap
mysqlaccess
mysql_convert_table_format
mysql_find_rows
......
#!/usr/bin/perl
# Copyright (c) 2000-2002, 2004, 2006 MySQL AB, 2009 Sun Microsystems, Inc.
# Use is subject to license terms.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# This is a utility for MariaDB. It is not needed by any standard part
# of MariaDB.
# Usage: mysql_zap [-signal] [-f] [-t] pattern
# Configuration parameters.
$sig = ""; # Default to try all signals
$ans = "y";
$opt_f= 0;
$opt_t= 0;
$opt_a = "";
$BSD = -f '/vmunix' || $ENV{"OS"} eq "SunOS4";
$LINUX = $^O eq 'linux' || $^O eq 'darwin';
$pscmd = $BSD ? "/bin/ps -auxww" : $LINUX ? "/bin/ps axuw" : "/bin/ps -ef";
open(TTYIN, "</dev/tty") || die "can't read /dev/tty: $!";
open(TTYOUT, ">/dev/tty") || die "can't write /dev/tty: $!";
select(TTYOUT);
$| = 1;
select(STDOUT);
$SIG{'INT'} = 'cleanup';
while ($#ARGV >= $[ && $ARGV[0] =~ /^-/) {
if ($ARGV[0] =~ /(ZERO|HUP|INT|QUIT|ILL|TRAP|ABRT|EMT|FPE|KILL|BUS|SEGV|SYS|PIPE|ALRM|TERM|URG|STOP|TSTP|CONT|CLD|TTIN|TTOU|IO|XCPU|XFSZ|VTALRM|PROF|WINCH|LOST|USR1|USR2)/ || $ARGV[0] =~ /-(\d+)$/) {
$sig = $1;
} elsif ($ARGV[0] eq "-f") {
$opt_f=1;
} elsif ($ARGV[0] eq "-t") {
$opt_t=1;
$ans = "n";
}
elsif ($ARGV[0] eq "-a")
{
$opt_a = 1;
}
elsif ($ARGV[0] eq "-?" || $ARGV[0] eq "-I" || $ARGV[0] eq "--help")
{
&usage;
}
else {
print STDERR "$0: illegal argument $ARGV[0] ignored\n";
}
shift;
}
&usage if $#ARGV < 0;
if (!$opt_f)
{
if ($BSD) {
system "stty cbreak </dev/tty >/dev/tty 2>&1";
}
else {
system "stty", 'cbreak',
system "stty", 'eol', '^A';
}
}
open(PS, "$pscmd|") || die "can't run $pscmd: $!";
$title = <PS>;
print TTYOUT $title;
# Catch any errors with eval. A bad pattern, for instance.
eval <<'EOF';
process: while ($cand = <PS>)
{
chop($cand);
($user, $pid) = split(' ', $cand);
next if $pid == $$;
$found = !@ARGV;
if ($opt_a) { $found = 1; }
foreach $pat (@ARGV)
{
if ($opt_a)
{
if (! ($cand =~ $pat))
{
next process;
}
}
else
{
$found = 1 if $cand =~ $pat;
}
}
next if (!$found);
if (! $opt_f && ! $opt_t)
{
print TTYOUT "$cand? ";
read(TTYIN, $ans, 1);
print TTYOUT "\n" if ($ans ne "\n");
}
else
{
print TTYOUT "$cand\n";
}
if ($ans =~ /^y/i) { &killpid($sig, $pid); }
if ($ans =~ /^q/i) { last; }
}
EOF
&cleanup;
sub usage {
print <<EOF;
Usage: $0 [-signal] [-?Ift] [--help] pattern
Options: -I or -? "info" -f "force" -t "test".
Version 1.0
Kill processes that match the pattern.
If -f isn't given, ask user for confirmation for each process to kill.
If signal isn't given, try first with signal 15, then with signal 9.
If -t is given, the processes are only shown on stdout.
EOF
exit(1);
}
sub cleanup {
if ($BSD) {
system "stty -cbreak </dev/tty >/dev/tty 2>&1";
}
else {
system "stty", 'icanon';
system "stty", 'eol', '^@';
}
print "\n";
exit;
}
sub killpid {
local($signal,$pid) = @_;
if ($signal)
{
kill $signal,$pid;
}
else
{
print "kill -15\n";
kill 15, $pid;
for (1..5) {
sleep 2;
return if kill(0, $pid) == 0;
}
print "kill -9\n";
kill 9, $pid;
for (1..5) {
sleep 2;
return if kill(0, $pid) == 0;
}
print "$pid will not die!\n";
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment