summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2003-12-08 20:53:46 +0100
committerunknown <guilhem@mysql.com>2003-12-08 20:53:46 +0100
commit9a1cb59cd721a5a3a7e8a4ea1720fddc3d449892 (patch)
tree6ce1598fed7aede90007c24b8509c11d8edba8e7
parentc121a7357046a64463cdb597e0fd28d4015113e2 (diff)
downloadmariadb-git-9a1cb59cd721a5a3a7e8a4ea1720fddc3d449892.tar.gz
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.
-rw-r--r--sql/mysqld.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index daccfc52af4..9c68ae95ef2 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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());