diff options
-rw-r--r-- | main.c | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -82,13 +82,7 @@ static void toy_singleinit(struct toy_list *which, char *argv[]) { toys.which = which; toys.argv = argv; - - if (CFG_TOYBOX_I18N) { - // Deliberately try C.UTF-8 before the user's locale to work around users - // that choose non-UTF-8 locales. macOS doesn't support C.UTF-8 though. - if (!setlocale(LC_CTYPE, "C.UTF-8")) setlocale(LC_CTYPE, ""); - } - setlinebuf(stdout); + toys.toycount = ARRAY_LEN(toy_list); // Parse --help and --version for (almost) all commands if (CFG_TOYBOX_HELP_DASHDASH && !(which->flags & TOYFLAG_NOHELP) && argv[1]) { @@ -110,10 +104,17 @@ static void toy_singleinit(struct toy_list *which, char *argv[]) toys.optargs = argv+1; for (toys.optc = 0; toys.optargs[toys.optc]; toys.optc++); } - toys.old_umask = umask(0); - if (!(which->flags & TOYFLAG_UMASK)) umask(toys.old_umask); - toys.signalfd--; - toys.toycount = ARRAY_LEN(toy_list); + + if (!(which->flags & TOYFLAG_NOFORK)) { + toys.old_umask = umask(0); + if (!(which->flags & TOYFLAG_UMASK)) umask(toys.old_umask); + if (CFG_TOYBOX_I18N) { + // Deliberately try C.UTF-8 before the user's locale to work around users + // that choose non-UTF-8 locales. macOS doesn't support C.UTF-8 though. + if (!setlocale(LC_CTYPE, "C.UTF-8")) setlocale(LC_CTYPE, ""); + } + setlinebuf(stdout); + } } // Full init needed by multiplexer or reentrant calls, calls singleinit at end |