From f5051d07f196a8ff7aeaae762333d5aa2b824088 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 1 Aug 2017 19:47:20 +0100 Subject: ash: allow long-running nofork applets to be interrupted Nofork applets can't be interrupted with ctrl-c. This isn't an issue for most such applets because they do very little and won't run for very long. However 'yes' and 'seq 10000000' can't be interrupted in a interactive shell, which is awkward. As a special case ignore the nofork-ness of these applets if they're run from an interactive shell. This isn't foolproof as there are still ways to run them such that they can't be interrupted, but it helps. --- shell/ash.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 441da4d85..b06ed18f4 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10268,7 +10268,15 @@ evalcommand(union node *cmd, int flags) */ /* find_command() encodes applet_no as (-2 - applet_no) */ int applet_no = (- cmdentry.u.index - 2); - if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no)) { + if (applet_no >= 0 && APPLET_IS_NOFORK(applet_no) +#if ENABLE_PLATFORM_MINGW32 + /* + * Fork long-running nofork applets (e.g. yes) in interactive + * sessions. Otherwise ctrl-c won't let the user kill them. + */ + && !(iflag && long_running_applet(applet_no)) +#endif + ) { listsetvar(varlist.list, VEXPORT|VSTACK); /* run _main() */ status = run_nofork_applet(applet_no, argv); -- cgit v1.2.3-55-g6feb