Commit 56e49fd7 authored by guilhem@mysql.com's avatar guilhem@mysql.com

Create PID file with O_TRUNC, so that it is emptied before it is written to.

Otherwise, if the previous run ended with a crash, and the PID was 1234,
and you have rebooted the machine and the new PID is 99 then in the PID
file you will have 9934.
Note: users of mysqld_safe did not have the problem because this script
deletes the PID file before starting mysqld.
parent 4d79120e
......@@ -1461,7 +1461,8 @@ static void start_signal_handler(void)
if (!opt_bootstrap)
{
File pidFile;
if ((pidFile = my_create(pidfile_name,0664, O_WRONLY, MYF(MY_WME))) >= 0)
if ((pidFile = my_create(pidfile_name,0664,
O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0)
{
char buff[21];
sprintf(buff,"%lu",(ulong) getpid());
......@@ -1754,7 +1755,8 @@ extern "C" void *signal_hand(void *arg __attribute__((unused)))
if (!opt_bootstrap)
{
File pidFile;
if ((pidFile = my_create(pidfile_name,0664, O_WRONLY, MYF(MY_WME))) >= 0)
if ((pidFile = my_create(pidfile_name,0664,
O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0)
{
char buff[21];
sprintf(buff,"%lu",(ulong) getpid());
......
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