aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-04 14:50:03 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-04 14:50:03 +0200
commitd329e34c96e0429602fe39489586cd61f97a2877 (patch)
tree07cf107ccb60bf27a7d605b3375215f8df1fea15 /shell
parent49e6bf2db92d896a71d08eb364069ba50fa82781 (diff)
downloadbusybox-d329e34c96e0429602fe39489586cd61f97a2877.tar.gz
ash: INT_OFF/INT_ON around run_nofork_applet()
function old new delta evalcommand 1441 1447 +6 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ca9926b54..2afa5e83d 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -9919,10 +9919,26 @@ evalcommand(union node *cmd, int flags)
int applet_no = (- cmdentry.u.index - 2);
if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) {
listsetvar(varlist.list, VEXPORT|VSTACK);
- /* run <applet>_main() */
-//FIXME: do we need INT_OFF / INT_ON here?
-//wouldn't open files and allocations leak on ^C otherwise?
+ /*
+ * Run <applet>_main().
+ * Signals (^C) can't interrupt here.
+ * Otherwise we can mangle stdio or malloc internal state.
+ * This makes applets which can run for a long time
+ * and/or wait for user input ineligible for NOFORK:
+ * for example, "yes" or "rm" (rm -i waits for input).
+ */
+ INT_OFF;
status = run_nofork_applet(applet_no, argv);
+ /*
+ * Try enabling NOFORK for "yes" applet.
+ * ^C _will_ stop it (write returns EINTR),
+ * but this causes stdout FILE to be stuck
+ * and needing clearerr(). What if other applets
+ * also can get EINTRs? Do we need to switch
+ * our signals to SA_RESTART?
+ */
+ /*clearerr(stdout);*/
+ INT_ON;
break;
}
#endif