main: (order) check pidfile earlier for running NM
We should check for conflicting process (pidfile) early on and error out.
This commit is contained in:
@@ -285,6 +285,8 @@ main (int argc, char *argv[])
|
||||
|
||||
nm_main_utils_ensure_root ();
|
||||
|
||||
nm_main_utils_ensure_not_running_pidfile (global_opt.pidfile);
|
||||
|
||||
if (!nm_logging_setup (global_opt.opt_log_level,
|
||||
global_opt.opt_log_domains,
|
||||
&bad_domains,
|
||||
@@ -332,8 +334,6 @@ main (int argc, char *argv[])
|
||||
|
||||
nm_main_utils_ensure_rundir ();
|
||||
|
||||
nm_main_utils_ensure_not_running_pidfile (global_opt.pidfile);
|
||||
|
||||
/* Read the config file and CLI overrides */
|
||||
config = nm_config_setup (config_cli, &error);
|
||||
nm_config_cmd_line_options_free (config_cli);
|
||||
|
@@ -378,6 +378,14 @@ main (int argc, char *argv[])
|
||||
exit (1);
|
||||
}
|
||||
|
||||
ifindex = if_nametoindex (global_opt.ifname);
|
||||
if (ifindex <= 0) {
|
||||
fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex);
|
||||
nm_main_utils_ensure_not_running_pidfile (pidfile);
|
||||
|
||||
if (!nm_logging_setup (global_opt.opt_log_level,
|
||||
global_opt.opt_log_domains,
|
||||
&bad_domains,
|
||||
@@ -395,14 +403,6 @@ main (int argc, char *argv[])
|
||||
|
||||
nm_main_utils_ensure_rundir ();
|
||||
|
||||
ifindex = if_nametoindex (global_opt.ifname);
|
||||
if (ifindex <= 0) {
|
||||
fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, ifindex);
|
||||
nm_main_utils_ensure_not_running_pidfile (pidfile);
|
||||
|
||||
if (global_opt.become_daemon && !global_opt.debug) {
|
||||
if (daemon (0, 0) < 0) {
|
||||
int saved_errno;
|
||||
|
Reference in New Issue
Block a user