]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix dhcpcd -n $int starting a new instance of dhcpcd if not running.
authorRoy Marples <roy@marples.name>
Sat, 9 May 2009 14:15:31 +0000 (14:15 +0000)
committerRoy Marples <roy@marples.name>
Sat, 9 May 2009 14:15:31 +0000 (14:15 +0000)
dhcpcd.c

index 52fc9b8035287b8829c2344dd4c85465432135bf..358df647c544ee0e19244f093867fac0926ee19e 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1596,31 +1596,31 @@ main(int argc, char **argv)
                    PACKAGE " will not work correctly unless run as root");
 
        if (sig != 0) {
-               i = -1;
                pid = read_pid();
                if (pid != 0)
                        syslog(LOG_INFO, "sending signal %d to pid %d",
                            sig, pid);
-
-               if (!pid || (i = kill(pid, sig))) {
+               if (pid == 0 || kill(pid, sig) != 0) {
                        if (sig != SIGALRM)
                                syslog(LOG_ERR, ""PACKAGE" not running");
                        unlink(pidfile);
-                       exit(EXIT_FAILURE);
-               }
-               if (sig == SIGALRM)
-                       exit(EXIT_SUCCESS);
-               /* Spin until it exits */
-               syslog(LOG_INFO, "waiting for pid %d to exit", pid);
-               ts.tv_sec = 0;
-               ts.tv_nsec = 100000000; /* 10th of a second */
-               for(i = 0; i < 100; i++) {
-                       nanosleep(&ts, NULL);
-                       if (read_pid() == 0)
+                       if (sig != SIGALRM)
+                               exit(EXIT_FAILURE);
+               } else {
+                       if (sig == SIGALRM)
                                exit(EXIT_SUCCESS);
+                       /* Spin until it exits */
+                       syslog(LOG_INFO, "waiting for pid %d to exit", pid);
+                       ts.tv_sec = 0;
+                       ts.tv_nsec = 100000000; /* 10th of a second */
+                       for(i = 0; i < 100; i++) {
+                               nanosleep(&ts, NULL);
+                               if (read_pid() == 0)
+                                       exit(EXIT_SUCCESS);
+                       }
+                       syslog(LOG_ERR, "pid %d failed to exit", pid);
+                       exit(EXIT_FAILURE);
                }
-               syslog(LOG_ERR, "pid %d failed to exit", pid);
-               exit(EXIT_FAILURE);
        }
 
        if (!(options & DHCPCD_TEST)) {