aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-02-05 19:11:54 -0600
committerRob Landley <rob@landley.net>2020-02-05 19:11:54 -0600
commit7274458bdeb8823bc2446692507a3eebb4cca044 (patch)
treea1e8a3856d19affe5e2baaee73b085f68eebc8c2
parent2f96b8601212ab9d28fc5a8b640ecc9ef7de251b (diff)
downloadtoybox-7274458bdeb8823bc2446692507a3eebb4cca044.tar.gz
Fiddle with main() comments.
-rw-r--r--main.c29
1 files changed, 8 insertions, 21 deletions
diff --git a/main.c b/main.c
index ded73d99..84178576 100644
--- a/main.c
+++ b/main.c
@@ -219,40 +219,27 @@ void toybox_main(void)
int main(int argc, char *argv[])
{
+ // don't segfault if our environment is crazy
if (!*argv) return 127;
// Snapshot stack location so we can detect recursion depth later.
- // This is its own block so probe doesn't permanently consume stack.
+ // Nommu has special reentry path, !stacktop = "vfork/exec self happened"
+ if (!CFG_TOYBOX_FORK && (0x80 & **argv)) **argv &= 0x7f;
else {
- int stack;
+ int stack_start; // here so probe var won't permanently eat stack
- toys.stacktop = &stack;
+ toys.stacktop = &stack_start;
}
- // Up to and including Android M, bionic's dynamic linker added a handler to
- // cause a crash dump on SIGPIPE. That was removed in Android N, but adbd
- // was still setting the SIGPIPE disposition to SIG_IGN, and its children
- // were inheriting that. In Android O, adbd is fixed, but manually asking
- // for the default disposition is harmless, and it'll be a long time before
- // no one's using anything older than O!
+ // Android before O had non-default SIGPIPE, 7 years = remove in Sep 2024.
if (CFG_TOYBOX_ON_ANDROID) signal(SIGPIPE, SIG_DFL);
- // If nommu can't fork, special reentry path.
- // Use !stacktop to signal "vfork happened", both before and after xexec()
- if (!CFG_TOYBOX_FORK) {
- if (0x80 & **argv) {
- **argv &= 0x7f;
- toys.stacktop = 0;
- }
- }
-
if (CFG_TOYBOX) {
- // Call the multiplexer, adjusting this argv[] to be its' argv[1].
- // (It will adjust it back before calling toy_exec().)
+ // Call the multiplexer with argv[] as its arguments so it can toy_find()
toys.argv = argv-1;
toybox_main();
} else {
- // a single toybox command built standalone with no multiplexer
+ // single command built standalone with no multiplexer is first list entry
toy_singleinit(toy_list, argv);
toy_list->toy_main();
}