fix command line in case the pid file is not set

This commit is contained in:
kakwa 2016-09-01 21:10:26 +02:00
parent b00bdbc5f9
commit e732e7cb8e
1 changed files with 6 additions and 4 deletions

View File

@ -82,7 +82,7 @@ int main(int argc, char **argv) {
init_pid(args.pidfile); init_pid(args.pidfile);
// get the full path for the pid file // get the full path for the pid file
char pid_file[PATH_MAX]; char pid_file[PATH_MAX];
if (realpath(args.pidfile, pid_file) == NULL) { if ((args.pidfile != NULL) && realpath(args.pidfile, pid_file) == NULL) {
syslog(LOG_CRIT, "unable to get the full path of the pid " syslog(LOG_CRIT, "unable to get the full path of the pid "
"file, uts-server start failed"); "file, uts-server start failed");
return EXIT_FAILURE; return EXIT_FAILURE;
@ -101,9 +101,11 @@ int main(int argc, char **argv) {
"uts-server daemon starting with conf '%s' from working dir '%s'", "uts-server daemon starting with conf '%s' from working dir '%s'",
conf_fp, conf_wd); conf_fp, conf_wd);
if (write_pid(pid_file) == 0) { if (args.pidfile != NULL) {
syslog(LOG_CRIT, "failed to write pid file '%s'", pid_file); if (write_pid(pid_file) == 0) {
return EXIT_FAILURE; syslog(LOG_CRIT, "failed to write pid file '%s'", pid_file);
return EXIT_FAILURE;
}
} }
while (1) { while (1) {