diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/executable.c | 11 | ||||
-rw-r--r-- | libbb/xfuncs_printf.c | 16 |
2 files changed, 26 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 | } | ||
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c index 4aa1b5ce2..e9222f690 100644 --- a/libbb/xfuncs_printf.c +++ b/libbb/xfuncs_printf.c | |||
@@ -659,3 +659,19 @@ pid_t FAST_FUNC xfork(void) | |||
659 | return pid; | 659 | return pid; |
660 | } | 660 | } |
661 | #endif | 661 | #endif |
662 | |||
663 | void FAST_FUNC xvfork_parent_waits_and_exits(void) | ||
664 | { | ||
665 | pid_t pid; | ||
666 | |||
667 | fflush_all(); | ||
668 | pid = xvfork(); | ||
669 | if (pid > 0) { | ||
670 | /* Parent */ | ||
671 | int exit_status = wait_for_exitstatus(pid); | ||
672 | if (WIFSIGNALED(exit_status)) | ||
673 | kill_myself_with_sig(WTERMSIG(exit_status)); | ||
674 | _exit(WEXITSTATUS(exit_status)); | ||
675 | } | ||
676 | /* Child continues */ | ||
677 | } | ||