diff --git a/src/main.c b/src/main.c index 1c18306b9e..e6b48c13ca 100644 --- a/src/main.c +++ b/src/main.c @@ -279,6 +279,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, @@ -326,8 +328,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_new (&error); if (config == NULL) { diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 1d842358c4..7d90bff812 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -381,6 +381,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, @@ -398,14 +406,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;