static char *pidfile;
/* Create pidfile even if one already exists and is locked? */
-static bool force;
+static bool overwrite_pidfile;
/* Should we chdir to "/". */
static bool chdir_ = true;
void
ignore_existing_pidfile(void)
{
- force = true;
+ overwrite_pidfile = true;
}
/* Sets up a following call to daemonize() to detach from the foreground
{
pid_t pid = already_running();
if (pid) {
- if (!force) {
+ if (!overwrite_pidfile) {
ovs_fatal(0, "%s: already running as pid %ld",
get_pidfile(), (long int) pid);
} else {
{
printf(
"\nDaemon options:\n"
- " -D, --detach run in background as daemon\n"
+ " --detach run in background as daemon\n"
" --no-chdir do not chdir to '/'\n"
- " -P, --pidfile[=FILE] create pidfile (default: %s/%s.pid)\n"
- " -f, --force with -P, start even if already running\n",
+ " --pidfile[=FILE] create pidfile (default: %s/%s.pid)\n"
+ " --overwrite-pidfile with --pidfile, start even if already "
+ "running\n",
ovs_rundir, program_name);
}
#include <sys/types.h>
enum {
- OPT_NO_CHDIR = UCHAR_MAX + 2048
+ OPT_DETACH = UCHAR_MAX + 2048,
+ OPT_NO_CHDIR,
+ OPT_OVERWRITE_PIDFILE,
+ OPT_PIDFILE,
};
-#define DAEMON_LONG_OPTIONS \
- {"detach", no_argument, 0, 'D'}, \
- {"no-chdir", no_argument, 0, OPT_NO_CHDIR}, \
- {"force", no_argument, 0, 'f'}, \
- {"pidfile", optional_argument, 0, 'P'}
+#define DAEMON_LONG_OPTIONS \
+ {"detach", no_argument, 0, OPT_DETACH}, \
+ {"no-chdir", no_argument, 0, OPT_NO_CHDIR}, \
+ {"pidfile", optional_argument, 0, OPT_PIDFILE}, \
+ {"overwrite-pidfile", no_argument, 0, OPT_OVERWRITE_PIDFILE}
#define DAEMON_OPTION_HANDLERS \
- case 'D': \
+ case OPT_DETACH: \
set_detach(); \
break; \
\
set_no_chdir(); \
break; \
\
- case 'P': \
+ case OPT_PIDFILE: \
set_pidfile(optarg); \
break; \
\
- case 'f': \
+ case OPT_OVERWRITE_PIDFILE: \
ignore_existing_pidfile(); \
break;
.TP
-\fB-P\fR[\fIpidfile\fR], \fB--pidfile\fR[\fB=\fIpidfile\fR]
+\fB--pidfile\fR[\fB=\fIpidfile\fR]
Causes a file (by default, \fB\*(PN.pid\fR) to be created indicating
the PID of the running process. If \fIpidfile\fR is not specified, or
if it does not begin with \fB/\fR, then it is created in
\fB@RUNDIR@\fR.
.TP
-\fB-f\fR, \fB--force\fR
-By default, when \fB-P\fR or \fB--pidfile\fR is specified and the
-specified pidfile already exists and is locked by a running process,
-\fB\*(PN\fR refuses to start. Specify \fB-f\fR or \fB--force\fR
-to cause it to instead overwrite the pidfile.
+\fB--overwrite-pidfile\fR
+By default, when \fB--pidfile\fR is specified and the specified pidfile
+already exists and is locked by a running process, \fB\*(PN\fR refuses
+to start. Specify \fB--overwrite-pidfile\fR to cause it to instead
+overwrite the pidfile.
-When \fB-P\fR or \fB--pidfile\fR is not specified, this option has no
-effect.
+When \fB--pidfile\fR is not specified, this option has no effect.
.TP
-\fB-D\fR, \fB--detach\fR
+\fB--detach\fR
Causes \fB\*(PN\fR to detach itself from the foreground session and
run as a background process.
.TP
\fB--no-chdir\fR
-By default, when \fB-D\fR or \fB--detach\fR is specified, \fB\*(PN\fR
+By default, when \fB--detach\fR is specified, \fB\*(PN\fR
changes its current working directory to the root directory after it
detaches. Otherwise, invoking \fB\*(PN\fR from a carelessly chosen
directory would prevent the administrator from unmounting the file
core dumps into the current working directory and the root directory
is not a good directory to use.
.IP
-This option has no effect when neither \fB-D\fR nor \fB--detach\fR is
-specified.
+This option has no effect when \fB--detach\fR is not specified.
\fB--exit-after-bind\fR.
.TP
-\fB-P\fR[\fIpidfile\fR], \fB--pidfile\fR[\fB=\fIpidfile\fR]
+\fB--pidfile\fR[\fB=\fIpidfile\fR]
Causes a file (by default, \fBovs\-discover.pid\fR) to be created indicating
the PID of the running process. If \fIpidfile\fR is not specified, or
if it does not begin with \fB/\fR, then it is created in
\fB--exit-after-bind\fR, or \fB--no-detach\fR is also given.
.TP
-\fB-f\fR, \fB--force\fR
-By default, when \fB-P\fR or \fB--pidfile\fR is specified and the
-specified pidfile already exists and is locked by a running process,
-\fBcontroller\fR refuses to start. Specify \fB-f\fR or \fB--force\fR
-to cause it to instead overwrite the pidfile.
-
-When \fB-P\fR or \fB--pidfile\fR is not specified, this option has no
-effect.
+\fB--overwrite-pidfile\fR
+By default, when \fB--pidfile\fR is specified and the specified pidfile
+already exists and is locked by a running process, \fBcontroller\fR refuses
+to start. Specify \fB--overwrite-pidfile\fR to cause it to instead
+overwrite the pidfile.
+
+When \fB--pidfile\fR is not specified, this option has no effect.
.so lib/vlog.man
.so lib/common.man
OPT_ACCEPT_VCONN = UCHAR_MAX + 1,
OPT_EXIT_WITHOUT_BIND,
OPT_EXIT_AFTER_BIND,
- OPT_NO_DETACH,
+ OPT_NO_DETACH
};
static struct option long_options[] = {
{"accept-vconn", required_argument, 0, OPT_ACCEPT_VCONN},
{"exit-after-bind", no_argument, 0, OPT_EXIT_AFTER_BIND},
{"no-detach", no_argument, 0, OPT_NO_DETACH},
{"timeout", required_argument, 0, 't'},
- {"pidfile", optional_argument, 0, 'P'},
- {"force", no_argument, 0, 'f'},
+ {"pidfile", optional_argument, 0, OPT_PIDFILE},
+ {"overwrite-pidfile", no_argument, 0, OPT_OVERWRITE_PIDFILE},
{"verbose", optional_argument, 0, 'v'},
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'V'},
detach_after_bind = false;
break;
- case 'P':
+ case OPT_PIDFILE:
set_pidfile(optarg);
break;
- case 'f':
+ case OPT_OVERWRITE_PIDFILE:
ignore_existing_pidfile();
break;
vlog_usage();
printf("\nOther options:\n"
" -t, --timeout=SECS give up discovery after SECS seconds\n"
- " -P, --pidfile[=FILE] create pidfile (default: %s/%s.pid)\n"
- " -f, --force with -P, start even if already running\n"
+ " --pidfile[=FILE] create pidfile (default: %s/%s.pid)\n"
+ " --overwrite-pidfile with --pidfile, start even if already "
+ "running\n"
" -h, --help display this help message\n"
" -V, --version display version information\n",
ovs_rundir, program_name);
if [ "$daemonize" != "y" ]; then
# Start in background and force a "success" message
action "Starting ovs-vswitchd ($strace_opt$valgrind_opt)" true
- (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$vswitchd" -P"$VSWITCHD_PIDFILE" -D $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF") &
+ (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF") &
else
- action "Starting ovs-vswitchd" nice -n "$VSWITCHD_PRIORITY" "$vswitchd" -P"$VSWITCHD_PIDFILE" -D $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF"
+ action "Starting ovs-vswitchd" nice -n "$VSWITCHD_PRIORITY" "$vswitchd" --pidfile="$VSWITCHD_PIDFILE" --detach $fake_proc_net_opt -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF"
fi
}
if [ "$daemonize" != "y" ]; then
# Start in background and force a "success" message
action "Starting ovs-brcompatd ($strace_opt$valgrind_opt)" true
- (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --appctl-command="$appctl_cmd" -P$BRCOMPATD_PIDFILE -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF") &
+ (nice -n "$VSWITCHD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF") &
else
- action "Starting ovs-brcompatd" nice -n "$BRCOMPATD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --appctl-command="$appctl_cmd" -P$BRCOMPATD_PIDFILE -D -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF"
+ action "Starting ovs-brcompatd" nice -n "$BRCOMPATD_PRIORITY" $strace_opt $valgrind_opt "$brcompatd" --appctl-command="$appctl_cmd" --pidfile=$BRCOMPATD_PIDFILE --detach -vANY:CONSOLE:EMER $syslog_opt $logfile_level_opt $logfile_file_opt $leak_opt "$VSWITCHD_CONF"
fi
}