diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-02 18:06:24 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-02 18:06:24 +0200 |
commit | 8220399173cf8d25e37059cadac96ac30f94e82a (patch) | |
tree | ffe5ae4a783c8ddeceda15f57eae74ee69feebea /libbb/executable.c | |
parent | c87e81f9440278dd46a3eddd1e0f4773afd46a95 (diff) | |
download | busybox-w32-8220399173cf8d25e37059cadac96ac30f94e82a.tar.gz busybox-w32-8220399173cf8d25e37059cadac96ac30f94e82a.tar.bz2 busybox-w32-8220399173cf8d25e37059cadac96ac30f94e82a.zip |
nsenter,unshare: share common code; fix a bug of not closing all fds
function old new delta
xvfork_parent_waits_and_exits - 64 +64
exec_prog_or_SHELL - 39 +39
unshare_main 873 810 -63
nsenter_main 663 596 -67
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/2 up/down: 106/-130) Total: -27 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb/executable.c')
-rw-r--r-- | libbb/executable.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libbb/executable.c b/libbb/executable.c index 85ecc3e6c..05e70312f 100644 --- a/libbb/executable.c +++ b/libbb/executable.c | |||
@@ -83,10 +83,19 @@ int FAST_FUNC BB_EXECVP(const char *file, char *const argv[]) | |||
83 | } | 83 | } |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | int FAST_FUNC BB_EXECVP_or_die(char **argv) | 86 | void FAST_FUNC BB_EXECVP_or_die(char **argv) |
87 | { | 87 | { |
88 | BB_EXECVP(argv[0], argv); | 88 | BB_EXECVP(argv[0], argv); |
89 | /* SUSv3-mandated exit codes */ | 89 | /* SUSv3-mandated exit codes */ |
90 | xfunc_error_retval = (errno == ENOENT) ? 127 : 126; | 90 | xfunc_error_retval = (errno == ENOENT) ? 127 : 126; |
91 | bb_perror_msg_and_die("can't execute '%s'", argv[0]); | 91 | bb_perror_msg_and_die("can't execute '%s'", argv[0]); |
92 | } | 92 | } |
93 | |||
94 | /* Typical idiom for applets which exec *optional* PROG [ARGS] */ | ||
95 | void FAST_FUNC exec_prog_or_SHELL(char **argv) | ||
96 | { | ||
97 | if (argv[0]) { | ||
98 | BB_EXECVP_or_die(argv); | ||
99 | } | ||
100 | run_shell(getenv("SHELL"), /*login:*/ 1, NULL, NULL); | ||
101 | } | ||