Updates from both Vladimir and Larry
[oweals/busybox.git] / busybox.c
index b4939e19d319a5dea4a3fbea596e7317921ec70f..9cc884854c1bf97bca8543cb7ad3e53fad1bcb9e 100644 (file)
--- a/busybox.c
+++ b/busybox.c
@@ -37,21 +37,7 @@ typedef int (*__link_f)(const char *, const char *);
  */
 static char *busybox_fullpath()
 {
-       pid_t pid;
-       char path[256];
-       char proc[256];
-       int len;
-
-       pid = getpid();
-       sprintf(proc, "/proc/%d/exe", pid);
-       len = readlink(proc, path, 256);
-       if (len != -1) {
-               path[len] = 0;
-       } else {
-               perror_msg("%s", proc);
-               return NULL;
-       }
-       return strdup(path);
+       return xreadlink("/proc/self/exe");
 }
 
 /* create (sym)links for each applet */
@@ -96,9 +82,13 @@ int main(int argc, char **argv)
        }
 #endif
 
-#ifdef BB_LOCALE_SUPPORT
+#ifdef BB_LOCALE_SUPPORT 
+#ifdef BB_INIT
        if(getpid()!=1) /* Do not set locale for `init' */
+#endif
+       {
                setlocale(LC_ALL, "");
+       }
 #endif
 
        run_applet_by_name(applet_name, argc, argv);