diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-11-07 16:17:40 -0700 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-11-07 16:17:40 -0700 |
commit | fa09f2cd7e74fc99d6699a7bcda60fc7135b6f0e (patch) | |
tree | 671a90572eef4a30c42fc8492c11b46e905f2e04 /tools | |
parent | c76c0836e4f5606615b42a8049fd747f542324da (diff) | |
download | mariadb-git-fa09f2cd7e74fc99d6699a7bcda60fc7135b6f0e.tar.gz |
manager clean-up ( added pid-file and kill in mysql-test-run when things go wrong)
fixes for IO_CACHE
need to pull Monty's fixes - this is not final, will not be pushed
include/my_sys.h:
IO_CACHE fixes
mysql-test/mysql-test-run.sh:
manager clean-up
mysys/mf_iocache.c:
IO_CACHE fix
sql/mysqld.cc:
more debug messages
tools/mysqlmanager.c:
added pid-file
Diffstat (limited to 'tools')
-rw-r--r-- | tools/mysqlmanager.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/tools/mysqlmanager.c b/tools/mysqlmanager.c index 5783d151107..0795b468033 100644 --- a/tools/mysqlmanager.c +++ b/tools/mysqlmanager.c @@ -189,6 +189,8 @@ static void run_launcher_loop(); int to_launcher_pipe[2],from_launcher_pipe[2]; pid_t launcher_pid; int in_segfault=0; +const char* pid_file = "/var/run/mysqlmanager.pid"; +int created_pid_file = 0; struct manager_cmd { @@ -283,6 +285,7 @@ struct option long_options[] = {"one-thread",no_argument,0,'d'}, {"connect-retries",required_argument,0,'C'}, {"password-file",required_argument,0,'p'}, + {"pid-file",required_argument,0,'f'}, {"version", no_argument, 0, 'V'}, {0, 0, 0, 0} }; @@ -327,6 +330,17 @@ LOG_MSG_FUNC(log_debug,LOG_DEBUG) void log_debug(const char* __attribute__((unused)) fmt,...) {} #endif +static void handle_sigterm(int sig) +{ + log_info("Got SIGTERM"); + if (!one_thread) + { + kill(launcher_pid,SIGTERM); + pthread_kill(loop_th,SIGTERM); + } + clean_up(); + exit(0); +} static void handle_segfault(int sig) { @@ -1250,6 +1264,8 @@ static void clean_up() if (errfp != stderr) fclose(errfp); hash_free(&exec_hash); + if (created_pid_file) + my_delete(pid_file, MYF(0)); } static void print_version(void) @@ -1287,7 +1303,7 @@ static void usage() static int parse_args(int argc, char **argv) { int c, option_index = 0; - while ((c=getopt_long(argc,argv,"P:?#:Vl:b:B:g:m:dC:p:", + while ((c=getopt_long(argc,argv,"P:?#:Vl:b:B:g:m:dC:p:f:", long_options,&option_index)) != EOF) { switch (c) @@ -1301,6 +1317,9 @@ static int parse_args(int argc, char **argv) case 'p': manager_pw_file=optarg; break; + case 'f': + pid_file=optarg; + break; case 'C': manager_connect_retries=atoi(optarg); break; @@ -1662,6 +1681,16 @@ static void init_user_hash() fclose(f); } +static void init_pid_file() +{ + FILE* fp = fopen(pid_file, "w"); + if (!fp) + die("Could not open pid file %s", pid_file); + created_pid_file=1; + fprintf(fp, "%d\n", getpid()); + fclose(fp); +} + static void init_globals() { pthread_attr_t thr_attr; @@ -1680,8 +1709,10 @@ static void init_globals() /* (void) pthread_attr_destroy(&thr_attr); */ } init_user_hash(); + init_pid_file(); loop_th=pthread_self(); signal(SIGPIPE,handle_sigpipe); + signal(SIGTERM,handle_sigterm); } static int open_and_dup(int fd,char* path) |