ifdown: use /var/run/udhcpc.%iface%.pid only if it exists
authorDenys Vlasenko <vda.linux@googlemail.com>
Sun, 2 May 2010 18:30:28 +0000 (20:30 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sun, 2 May 2010 18:30:28 +0000 (20:30 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/ifupdown.c

index bf88b1c19bfdf95713c526011ce0e1fbed5f76ef..2f3dd1d7bed6209d507aafd45fa096c2d29513f7 100644 (file)
@@ -573,8 +573,10 @@ static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec)
 static int FAST_FUNC dhcp_down(struct interface_defn_t *ifd, execfn *exec)
 {
        int result;
-       result = execute("kill "
-                      "`cat /var/run/udhcpc.%iface%.pid` 2>/dev/null", ifd, exec);
+       result = execute(
+               "test -f /var/run/udhcpc.%iface%.pid && "
+               "kill `cat /var/run/udhcpc.%iface%.pid` 2>/dev/null",
+               ifd, exec);
        /* Also bring the hardware interface down since
           killing the dhcp client alone doesn't do it.
           This enables consecutive ifup->ifdown->ifup */