#include "util.h"
#include "vlog.h"
-VLOG_DEFINE_THIS_MODULE(daemon)
+VLOG_DEFINE_THIS_MODULE(daemon);
/* --detach: Should we run in the background? */
static bool detach;
make_pidfile_name(const char *name)
{
return (!name
- ? xasprintf("%s/%s.pid", ovs_rundir, program_name)
- : abs_file_name(ovs_rundir, name));
+ ? xasprintf("%s/%s.pid", ovs_rundir(), program_name)
+ : abs_file_name(ovs_rundir(), name));
}
/* Sets up a following call to daemonize() to create a pidfile named 'name'.
ovs_fatal(errno, "waitpid failed");
} else if (retval == daemon_pid) {
char *s = process_status_msg(status);
- free(status_msg);
- status_msg = xasprintf("%d crashes: pid %lu died, %s",
- ++crashes,
- (unsigned long int) daemon_pid, s);
- free(s);
-
if (should_restart(status)) {
+ free(status_msg);
+ status_msg = xasprintf("%d crashes: pid %lu died, %s",
+ ++crashes,
+ (unsigned long int) daemon_pid, s);
+ free(s);
+
if (WCOREDUMP(status)) {
/* Disable further core dumps to save disk space. */
struct rlimit r;
break;
}
} else {
- VLOG_INFO("%s, exiting", status_msg);
+ VLOG_INFO("pid %lu died, %s, exiting",
+ (unsigned long int) daemon_pid, s);
+ free(s);
exit(0);
}
}
" --pidfile[=FILE] create pidfile (default: %s/%s.pid)\n"
" --overwrite-pidfile with --pidfile, start even if already "
"running\n",
- ovs_rundir, program_name);
+ ovs_rundir(), program_name);
}
/* Opens and reads a PID from 'pidfile'. Returns the nonnegative PID if