Changeset 746 for vendor/current/source3/lib/pidfile.c
- Timestamp:
- Nov 27, 2012, 4:56:06 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/lib/pidfile.c
r740 r746 31 31 /* return the pid in a pidfile. return 0 if the process (or pidfile) 32 32 does not exist */ 33 pid_t pidfile_pid(const char * name)33 pid_t pidfile_pid(const char *program_name) 34 34 { 35 35 int fd; … … 37 37 pid_t pid; 38 38 unsigned int ret; 39 char *name; 40 const char *short_configfile; 39 41 char * pidFile; 40 42 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 41 62 if (asprintf(&pidFile, "%s/%s.pid", lp_piddir(), name) == -1) { 63 SAFE_FREE(name); 42 64 return 0; 43 65 } 66 67 SAFE_FREE(name); 44 68 45 69 fd = sys_open(pidFile, O_NONBLOCK | O_RDONLY, 0644);
Note:
See TracChangeset
for help on using the changeset viewer.