Merge commit '215b0ca6e4fe466c6942d21a1bba62d97f2d5e5d'

# Conflicts:
#	libbb/appletlib.c
#	shell/hush.c
#	shell/hush_test/run-all
This commit is contained in:
Stephen Heumann 2018-01-01 13:26:37 -06:00
commit 6143432e64
2 changed files with 22 additions and 4 deletions

View File

@ -1813,11 +1813,11 @@ static void hush_exit(int exitcode)
}
#endif
#if ENABLE_HUSH_JOB
fflush_all();
#if ENABLE_HUSH_JOB
sigexit(- (exitcode & 0xff));
#else
exit(exitcode);
_exit(exitcode);
#endif
}
@ -6912,7 +6912,23 @@ static void dump_cmd_in_x_mode(char **argv)
* Never returns.
* Don't exit() here. If you don't exec, use _exit instead.
* The at_exit handlers apparently confuse the calling process,
* in particular stdin handling. Not sure why? -- because of vfork! (vda) */
* in particular stdin handling. Not sure why? -- because of vfork! (vda)
* Also, it was observed that on exit(), fgetc'ed buffered data
* gets "unwound" by some libcs, via lseek(fd, -NUM, SEEK_CUR).
* With the net effect that even after fork(), not vfork(),
* exit() in NOEXECed applet in "sh SCRIPT":
* noexec_applet_here
* echo END_OF_SCRIPT
* lseeks fd in input FILE object from EOF to "e" in "echo END_OF_SCRIPT".
* This makes "echo END_OF_SCRIPT" executed twice. exexit() is the fix.
*/
#if ENABLE_FEATURE_SH_STANDALONE
static void exexit(void)
{
fflush_all();
_exit(xfunc_error_retval);
}
#endif
static void pseudo_exec_argv(nommu_save_t *nommu_save,
char **argv, int assignment_cnt,
char **argv_expanded) NORETURN;
@ -6993,6 +7009,7 @@ static NOINLINE void pseudo_exec_argv(nommu_save_t *nommu_save,
# if BB_MMU /* see above why on NOMMU it is not allowed */
if (APPLET_IS_NOEXEC(a)) {
debug_printf_exec(("running applet '%s'\n", argv[0]));
die_func = exexit;
run_applet_no_and_exit(a, argv);
}
# endif

View File

@ -71,6 +71,7 @@ do_test()
echo -n "$1/$x:"
(
"$THIS_SH" "./$x" >"$name.xx" 2>&1
r=$?
# filter C library differences
sed \
-e "/: invalid option /s:'::g" \
@ -81,7 +82,7 @@ do_test()
else
ln -s "$name.right" "$name.rt"
fi
test $? -eq 77 && rm -f "../$1/${x%%.tests}.fail" && exit 77
test $r -eq 77 && rm -f "../$1/${x%%.tests}.fail" && exit 77
diff -u "$name.xx" "$name.rt" >"../$1/${x%%.tests}.fail" && rm -f "$name.xx" "../$1/${x%%.tests}.fail"
)
case $? in