mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-09 04:10:18 +01:00
main: (order) check pidfile earlier for running NM
We should check for conflicting process (pidfile)
early on and error out.
(cherry picked from commit af2b44cb43)
This commit is contained in:
parent
f8430aaa9f
commit
bc2ea72a79
2 changed files with 10 additions and 10 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue