udhcpc: code shrink
[oweals/busybox.git] / debianutils / start_stop_daemon.c
index c8b7fa8f21d912b3cfdb0ef735b350cdcb2359da..43b6fca260429187d758733d334ec09818cea049 100644 (file)
@@ -116,8 +116,6 @@ Misc options:
 //usage:       )
 //usage:     "\n       -q              Quiet"
 
-#include <sys/resource.h>
-
 /* Override ENABLE_FEATURE_PIDFILE */
 #define WANT_PIDFILE 1
 #include "libbb.h"
@@ -159,6 +157,9 @@ struct globals {
        unsigned execname_sizeof;
        int user_id;
        smallint signal_nr;
+#ifdef OLDER_VERSION_OF_X
+       struct stat execstat;
+#endif
 } FIX_ALIASING;
 #define G (*(struct globals*)bb_common_bufsiz1)
 #define userspec          (G.userspec            )
@@ -186,13 +187,12 @@ static int pid_is_exec(pid_t pid)
        sprintf(buf, "/proc/%u/exe", (unsigned)pid);
        if (stat(buf, &st) < 0)
                return 0;
-       if (st.st_dev == execstat.st_dev
-        && st.st_ino == execstat.st_ino)
+       if (st.st_dev == G.execstat.st_dev
+        && st.st_ino == G.execstat.st_ino)
                return 1;
        return 0;
 }
-#endif
-
+#else
 static int pid_is_exec(pid_t pid)
 {
        ssize_t bytes;
@@ -216,6 +216,7 @@ static int pid_is_exec(pid_t pid)
        }
        return 0;
 }
+#endif
 
 static int pid_is_name(pid_t pid)
 {
@@ -410,9 +411,6 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
        char *signame;
        char *startas;
        char *chuid;
-#ifdef OLDER_VERSION_OF_X
-       struct stat execstat;
-#endif
 #if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
 //     char *retry_arg = NULL;
 //     int retries = -1;
@@ -481,7 +479,7 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
 
 #ifdef OLDER_VERSION_OF_X
        if (execname)
-               xstat(execname, &execstat);
+               xstat(execname, &G.execstat);
 #endif
 
        *--argv = startas;