From e2837a9107f8a68a790908d609c0c8dab17d7bdd Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 3 Apr 2015 09:06:52 -0700 Subject: [PATCH] Remove execonce. Use 'exec' instead. Change-Id: I1320d1971f7cd8b23753c27aa87089006e112a11 --- init/builtins.cpp | 62 -------------------------------------------- init/init_parser.cpp | 1 - init/keywords.h | 2 -- init/readme.txt | 4 --- 4 files changed, 69 deletions(-) diff --git a/init/builtins.cpp b/init/builtins.cpp index 9d5b8a830..ff6c9376f 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -154,68 +154,6 @@ int do_exec(int nargs, char** args) { return 0; } -// TODO: remove execonce when exec is available. -int do_execonce(int nargs, char **args) -{ - pid_t child; - int child_status = 0; - static int already_done; - - if (already_done) { - return -1; - } - already_done = 1; - if (!(child = fork())) { - /* - * Child process. - */ - zap_stdio(); - char *exec_args[100]; - size_t num_process_args = nargs; - - memset(exec_args, 0, sizeof(exec_args)); - if (num_process_args > ARRAY_SIZE(exec_args) - 1) { - ERROR("exec called with %zu args, limit is %zu", num_process_args, - ARRAY_SIZE(exec_args) - 1); - _exit(1); - } - for (size_t i = 1; i < num_process_args; i++) - exec_args[i - 1] = args[i]; - - if (execv(exec_args[0], exec_args) == -1) { - ERROR("Failed to execv '%s' (%s)", exec_args[0], strerror(errno)); - _exit(1); - } - ERROR("Returned from execv()!"); - _exit(1); - } - - /* - * Parent process. - */ - if (child == -1) { - ERROR("Fork failed\n"); - return -1; - } - - if (TEMP_FAILURE_RETRY(waitpid(child, &child_status, 0)) == -1) { - ERROR("waitpid(): failed (%s)\n", strerror(errno)); - return -1; - } - - if (WIFSIGNALED(child_status)) { - INFO("Child exited due to signal %d\n", WTERMSIG(child_status)); - return -1; - } else if (WIFEXITED(child_status)) { - INFO("Child exited normally (exit code %d)\n", WEXITSTATUS(child_status)); - return WEXITSTATUS(child_status); - } - - ERROR("Abnormal child process exit\n"); - - return -1; -} - int do_export(int nargs, char **args) { return add_environment(args[1], args[2]); diff --git a/init/init_parser.cpp b/init/init_parser.cpp index 593f0c56b..af935d715 100644 --- a/init/init_parser.cpp +++ b/init/init_parser.cpp @@ -138,7 +138,6 @@ static int lookup_keyword(const char *s) case 'e': if (!strcmp(s, "nable")) return K_enable; if (!strcmp(s, "xec")) return K_exec; - if (!strcmp(s, "xeconce")) return K_execonce; if (!strcmp(s, "xport")) return K_export; break; case 'g': diff --git a/init/keywords.h b/init/keywords.h index 4bd0ba630..059dde126 100644 --- a/init/keywords.h +++ b/init/keywords.h @@ -6,7 +6,6 @@ int do_class_reset(int nargs, char **args); int do_domainname(int nargs, char **args); int do_enable(int nargs, char **args); int do_exec(int nargs, char **args); -int do_execonce(int nargs, char **args); int do_export(int nargs, char **args); int do_hostname(int nargs, char **args); int do_ifup(int nargs, char **args); @@ -55,7 +54,6 @@ enum { KEYWORD(domainname, COMMAND, 1, do_domainname) KEYWORD(enable, COMMAND, 1, do_enable) KEYWORD(exec, COMMAND, 1, do_exec) - KEYWORD(execonce, COMMAND, 1, do_execonce) KEYWORD(export, COMMAND, 2, do_export) KEYWORD(group, OPTION, 0, 0) KEYWORD(hostname, COMMAND, 1, do_hostname) diff --git a/init/readme.txt b/init/readme.txt index 630dd034c..84afd11d8 100644 --- a/init/readme.txt +++ b/init/readme.txt @@ -182,10 +182,6 @@ exec [ [ [ ]* ] ] -- [ ]* groups can be provided. No other commands will be run until this one finishes. -execonce [ ]* - Use exec instead. This command will be removed after existing callers have - moved to exec. - export Set the environment variable equal to in the global environment (which will be inherited by all processes