Changeset 96

Show
Ignore:
Timestamp:
10/01/07 11:10:20 (14 months ago)
Author:
psmedley
Message:

Don't free pidFile until we've closed it

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/samba/source/lib/pidfile.c

    r77 r96  
    3939                return 0; 
    4040        } 
     41 
    4142        fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644); 
    4243        if (fd == -1) { 
     
    5051                goto noproc; 
    5152        } 
    52  
    5353        ret = atoi(pidstr); 
    5454        if (ret == 0) { 
     
    6464                goto noproc; 
    6565        } 
    66  
    6766#ifndef __OS2__ 
    6867        /* if we lock the file, we won't be able to read it later on OS/2 */ 
     
    7776 
    7877 noproc: 
     78#ifndef __OS2__ 
    7979        SAFE_FREE(pidFile); 
    8080        close(fd); 
    8181        unlink(pidFile); 
     82#else 
     83        close(fd); 
     84        unlink(pidFile); 
     85        SAFE_FREE(pidFile); 
     86#endif 
    8287        return 0; 
    8388} 
     
    113118#else 
    114119        /* On OS/2, CONFIGFILE will always be different to dyn_CONFIGFILE as dyn_CONFIGFILE dynamically looks up the system ETC directory */ 
    115         strncpy( name, program_name, sizeof( name)-1); 
     120        name = SMB_STRDUP(program_name); 
    116121#endif 
    117122        if (asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name) == -1) { 
     
    119124        } 
    120125 
    121  
     126                DEBUG(0,("PS1\n")); 
    122127        pid = pidfile_pid(name); 
     128                DEBUG(0,("PS2\n")); 
    123129        if (pid != 0) { 
    124130                DEBUG(0,("ERROR: %s is already running. File %s exists and process id %d is running.\n",  
     
    139145                exit(1); 
    140146        } 
    141  
    142147        memset(buf, 0, sizeof(buf)); 
    143148        slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());