On Wed, Nov 8, 2023 at 3:58 AM Dominique Martinet
<asmad...@codewreck.org> wrote:
>
> From: Dominique Martinet <dominique.marti...@atmark-techno.com>
>
> On alpine linux, calling busybox time with a nonexisting command would
> hang forever:
> ```
> time: can't execute 'fdsa': No such file or directory
> Command exited with non-zero status 127
> real    0m 0.00s
> user    0m 0.00s
> sys     0m 0.00s
> <hang>
> ```
>
> This is because time uses vfork then BB_EXECVP_or_die, which ultimately
> calls exit() after execvp fails. exit() is explicitly listed as unsafe
> to call after vfork as the child process shares its memory with the
> parent; in particular on musl exit will take the init_fini_lock() and
> calling it twice in the same address space will just hang.
> _exit() on the other hand is safe to call, so replace die_func with it.

Doesn't happen to me... maybe I have an older musl.

> For this particular problem die_func could just be overriden in
> time.c's run_command after vfork, but this problem actually came up
> before in shell/hush.c as per the fflush_and__exit comment so it seems
> more appropriate to do this globally in the xvfork macro and get rid of
> this whole class of bugs forever.

Maybe we can always use _exit(),
or fflush_all(); _exit() in xfunc_die()?
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to