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. --- libbb/appletlib.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libbb') diff --git a/libbb/appletlib.c b/libbb/appletlib.c index 3cdf0c613..401475f18 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -310,6 +310,22 @@ int FAST_FUNC find_applet_by_name(const char *name) #endif } +# if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_NOFORK +int FAST_FUNC long_running_applet(int applet_no) +{ + int ret = 0; + +#if defined(APPLET_NO_seq) + ret |= (applet_no == APPLET_NO_seq); +#endif +#if defined(APPLET_NO_yes) + ret |= (applet_no == APPLET_NO_yes); +#endif + + return ret; +} +#endif + void lbb_prepare(const char *applet IF_FEATURE_INDIVIDUAL(, char **argv)) -- cgit v1.2.3-55-g6feb