~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/signal_handler/signal_handler.cc

  • Committer: Monty Taylor
  • Date: 2009-03-06 03:33:24 UTC
  • mfrom: (916.1.2 merge)
  • Revision ID: mordred@inaugust.com-20090306033324-dcedf80g9qzywbvu
Merged Brian's merge... re-rotate the tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
*/
76
76
static void create_pid_file()
77
77
{
78
 
  File file;
79
 
  if ((file = my_create(pidfile_name,0664,
80
 
                        O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0)
 
78
  int file;
 
79
  char buff[1024];
 
80
 
 
81
  assert(pidfile_name[0]);
 
82
  if ((file = open(pidfile_name, O_CREAT|O_WRONLY|O_TRUNC, S_IRWXU|S_IRGRP|S_IROTH)) > 0)
81
83
  {
82
 
    char buff[21], *end;
83
 
    end= int10_to_str((long) getpid(), buff, 10);
84
 
    *end++= '\n';
85
 
    if (!my_write(file, (unsigned char*) buff, (uint32_t) (end-buff), MYF(MY_WME | MY_NABP)))
 
84
    int length;
 
85
 
 
86
    length= snprintf(buff, 1024, "%ld\n", (long) getpid()); 
 
87
 
 
88
    if ((write(file, buff, length)) == length)
86
89
    {
87
 
      (void) my_close(file, MYF(0));
88
 
      return;
 
90
      if (close(file) != -1)
 
91
        return;
89
92
    }
90
 
    (void) my_close(file, MYF(0));
 
93
    (void)close(file); /* We can ignore the error, since we are going to error anyway at this point */
91
94
  }
92
 
  sql_perror("Can't start server: can't create PID file");
 
95
  snprintf(buff, 1024, "Can't start server: can't create PID file (%s)", pidfile_name);
 
96
  sql_perror(buff);
93
97
  exit(1);
94
98
}
95
99