Ignore:
Timestamp:
Nov 29, 2012, 1:59:04 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/lib/pidfile.c

    r745 r751  
    3131/* return the pid in a pidfile. return 0 if the process (or pidfile)
    3232   does not exist */
    33 pid_t pidfile_pid(const char *name)
     33pid_t pidfile_pid(const char *program_name)
    3434{
    3535        int fd;
     
    3737        pid_t pid;
    3838        unsigned int ret;
     39        char *name;
     40        const char *short_configfile;
    3941        char * pidFile;
    4042
     43        /* Add a suffix to the program name if this is a process with a
     44         * none default configuration file name. */
     45        if (strcmp( CONFIGFILE, get_dyn_CONFIGFILE()) == 0) {
     46                name = SMB_STRDUP(program_name);
     47        } else {
     48                short_configfile = strrchr( get_dyn_CONFIGFILE(), '/');
     49                if (short_configfile == NULL) {
     50                        /* conf file in current directory */
     51                        short_configfile = get_dyn_CONFIGFILE();
     52                } else {
     53                        /* full/relative path provided */
     54                        short_configfile++;
     55                }
     56                if (asprintf(&name, "%s-%s", program_name,
     57                                short_configfile) == -1) {
     58                        smb_panic("asprintf failed");
     59                }
     60        }
     61
    4162        if (asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name) == -1) {
     63                SAFE_FREE(name);
    4264                return 0;
    4365        }
     66
     67        SAFE_FREE(name);
    4468
    4569        fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
Note: See TracChangeset for help on using the changeset viewer.