Commit 8179ed26 authored by Bjorn Munch's avatar Bjorn Munch

Bug #43410 --skip-core-file has no effect if core file size is set

Would not prevent mysqld from core dumping
Passes --nocore arg to safe_process, which then sets rlimit core to 0 for child
parent 739d5775
...@@ -117,6 +117,7 @@ sub new { ...@@ -117,6 +117,7 @@ sub new {
my $output = delete($opts{'output'}); my $output = delete($opts{'output'});
my $error = delete($opts{'error'}); my $error = delete($opts{'error'});
my $verbose = delete($opts{'verbose'}); my $verbose = delete($opts{'verbose'});
my $nocore = delete($opts{'nocore'});
my $host = delete($opts{'host'}); my $host = delete($opts{'host'});
my $shutdown = delete($opts{'shutdown'}); my $shutdown = delete($opts{'shutdown'});
my $user_data= delete($opts{'user_data'}); my $user_data= delete($opts{'user_data'});
...@@ -137,6 +138,7 @@ sub new { ...@@ -137,6 +138,7 @@ sub new {
push(@safe_args, $safe_script) if defined $safe_script; push(@safe_args, $safe_script) if defined $safe_script;
push(@safe_args, "--verbose") if $verbose > 0; push(@safe_args, "--verbose") if $verbose > 0;
push(@safe_args, "--nocore") if $nocore;
# Point the safe_process at the right parent if running on cygwin # Point the safe_process at the right parent if running on cygwin
push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN; push(@safe_args, "--parent-pid=".Cygwin::pid_to_winpid($$)) if IS_CYGWIN;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/resource.h>
#include <unistd.h> #include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
...@@ -149,7 +150,8 @@ int main(int argc, char* const argv[] ) ...@@ -149,7 +150,8 @@ int main(int argc, char* const argv[] )
char* const* child_argv= 0; char* const* child_argv= 0;
pid_t own_pid= getpid(); pid_t own_pid= getpid();
pid_t parent_pid= getppid(); pid_t parent_pid= getppid();
bool nocore = false;
/* Install signal handlers */ /* Install signal handlers */
signal(SIGTERM, handle_signal); signal(SIGTERM, handle_signal);
signal(SIGINT, handle_signal); signal(SIGINT, handle_signal);
...@@ -181,6 +183,9 @@ int main(int argc, char* const argv[] ) ...@@ -181,6 +183,9 @@ int main(int argc, char* const argv[] )
start++; /* Step past = */ start++; /* Step past = */
if ((parent_pid= atoi(start)) == 0) if ((parent_pid= atoi(start)) == 0)
die("Invalid value '%s' passed to --parent-id", start); die("Invalid value '%s' passed to --parent-id", start);
} else if ( strcmp(arg, "--nocore") == 0 )
{
nocore = true; // Don't allow the process to dump core
} }
else else
die("Unknown option: %s", arg); die("Unknown option: %s", arg);
...@@ -218,6 +223,15 @@ int main(int argc, char* const argv[] ) ...@@ -218,6 +223,15 @@ int main(int argc, char* const argv[] )
// it and any childs(that hasn't changed group themself) // it and any childs(that hasn't changed group themself)
setpgid(0, 0); setpgid(0, 0);
if (nocore)
{
struct rlimit corelim = { 0, 0 };
if (setrlimit (RLIMIT_CORE, &corelim) < 0)
{
message("setrlimit failed, errno=%d", errno);
}
}
// Signal that child is ready // Signal that child is ready
buf= 37; buf= 37;
write(pfd[1], &buf, 1); write(pfd[1], &buf, 1);
......
...@@ -190,6 +190,8 @@ my $build_thread= 0; ...@@ -190,6 +190,8 @@ my $build_thread= 0;
my $opt_record; my $opt_record;
my $opt_report_features; my $opt_report_features;
my $opt_skip_core;
our $opt_check_testcases= 1; our $opt_check_testcases= 1;
my $opt_mark_progress; my $opt_mark_progress;
...@@ -4008,6 +4010,7 @@ sub mysqld_arguments ($$$) { ...@@ -4008,6 +4010,7 @@ sub mysqld_arguments ($$$) {
mtr_add_arg($args, "%s", $arg); mtr_add_arg($args, "%s", $arg);
} }
} }
$opt_skip_core = $found_skip_core;
if ( !$found_skip_core ) if ( !$found_skip_core )
{ {
mtr_add_arg($args, "%s", "--core-file"); mtr_add_arg($args, "%s", "--core-file");
...@@ -4105,6 +4108,7 @@ sub mysqld_start ($$) { ...@@ -4105,6 +4108,7 @@ sub mysqld_start ($$) {
error => $output, error => $output,
append => 1, append => 1,
verbose => $opt_verbose, verbose => $opt_verbose,
nocore => $opt_skip_core,
host => undef, host => undef,
shutdown => sub { mysqld_stop($mysqld) }, shutdown => sub { mysqld_stop($mysqld) },
); );
......
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