203 system(mkdir_cmd); |
203 system(mkdir_cmd); |
204 free(mkdir_cmd); |
204 free(mkdir_cmd); |
205 |
205 |
206 char *pid_file_path = NULL; |
206 char *pid_file_path = NULL; |
207 asprintf(&pid_file_path, "%s/pid", cfg->tmp.ptr); |
207 asprintf(&pid_file_path, "%s/pid", cfg->tmp.ptr); |
208 FILE *pidfile = fopen(pid_file_path, "w"); // TODO: check error |
208 FILE *pidfile = fopen(pid_file_path, "w"); |
|
209 if(!pidfile) { |
|
210 log_ereport(LOG_FAILURE, "cannot open pid file %s: %s", pid_file_path, strerror(errno)); |
|
211 return -1; |
|
212 } |
209 pid_t pid = getpid(); |
213 pid_t pid = getpid(); |
210 fprintf(pidfile, "%d", pid); |
214 fprintf(pidfile, "%d", pid); |
211 fclose(pidfile); |
215 fclose(pidfile); |
212 free(pid_file_path); |
216 free(pid_file_path); |
213 |
217 |