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/xfuncs_printf.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/xfuncs_printf.c')
-rw-r--r-- | libbb/xfuncs_printf.c | 16 |
1 files changed, 16 insertions, 0 deletions
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 | } | ||