Try to make indent formatting less horrible
[oweals/busybox.git] / libbb / run_parts.c
index 7829a84baafd25646b25c7970f2af5374db631d0..0eb766086bc77a54154a810c43214d6a5c15837c 100644 (file)
@@ -47,7 +47,7 @@ static int valid_name(const struct dirent *d)
  * test_mode = 2 means to fail siliently on missing directories
  */
 
-extern int run_parts(char **args, const unsigned char test_mode)
+extern int run_parts(char **args, const unsigned char test_mode, char **env)
 {
        struct dirent **namelist = 0;
        struct stat st;
@@ -69,7 +69,7 @@ extern int run_parts(char **args, const unsigned char test_mode)
                if (test_mode & 2) {
                        return(2);
                }
-               perror_msg_and_die("failed to open directory %s", arg0);
+               bb_perror_msg_and_die("failed to open directory %s", arg0);
        }
 
        for (i = 0; i < entries; i++) {
@@ -77,10 +77,10 @@ extern int run_parts(char **args, const unsigned char test_mode)
                filename = concat_path_file(arg0, namelist[i]->d_name);
 
                if (stat(filename, &st) < 0) {
-                       perror_msg_and_die("failed to stat component %s", filename);
+                       bb_perror_msg_and_die("failed to stat component %s", filename);
                }
                if (S_ISREG(st.st_mode) && !access(filename, X_OK)) {
-                       if (test_mode & 1) {
+                       if (test_mode) {
                                puts(filename);
                        } else {
                                /* exec_errno is common vfork variable */
@@ -89,10 +89,10 @@ extern int run_parts(char **args, const unsigned char test_mode)
                                int pid;
 
                                if ((pid = vfork()) < 0) {
-                                       perror_msg_and_die("failed to fork");
+                                       bb_perror_msg_and_die("failed to fork");
                                } else if (!pid) {
                                        args[0] = filename;
-                                       execv(filename, args);
+                                       execve(filename, args, env);
                                        exec_errno = errno;
                                        _exit(1);
                                }
@@ -100,19 +100,20 @@ extern int run_parts(char **args, const unsigned char test_mode)
                                waitpid(pid, &result, 0);
                                if(exec_errno) {
                                        errno = exec_errno;
-                                       perror_msg_and_die("failed to exec %s", filename);
+                                       bb_perror_msg("failed to exec %s", filename);
+                                       exitstatus = 1;
                                }
                                if (WIFEXITED(result) && WEXITSTATUS(result)) {
-                                       perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result));
+                                       bb_perror_msg("%s exited with return code %d", filename, WEXITSTATUS(result));
                                        exitstatus = 1;
                                } else if (WIFSIGNALED(result)) {
-                                       perror_msg("%s exited because of uncaught signal %d", filename, WTERMSIG(result));
+                                       bb_perror_msg("%s exited because of uncaught signal %d", filename, WTERMSIG(result));
                                        exitstatus = 1;
                                }
                        }
                } 
                else if (!S_ISDIR(st.st_mode)) {
-                       error_msg("component %s is not an executable plain file", filename);
+                       bb_error_msg("component %s is not an executable plain file", filename);
                        exitstatus = 1;
                }