From e19dd7d618434be1336727a5113c1432ac3c6573 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 26 Sep 2021 08:59:03 +0100 Subject: ash: prevent exit if background jobs are present If the user exits from an interactive shell while background jobs are running the console window won't terminate because the background jobs are still connected to it. Warn the user when this happens. They can either shut down the background jobs themselves or close the console window. This is implemented by repurposing the stoppedjobs() function which is otherwise unused in the WIN32 port. --- 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 9f60b4350..0fa3d4dab 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -6077,7 +6077,15 @@ stoppedjobs(void) return retval; } #else -# define stoppedjobs() 0 +static int +stoppedjobs(void) +{ + if (iflag && curjob) { + out2str("You have background jobs.\n"); + return 1; + } + return 0; +} #endif -- cgit v1.2.3-55-g6feb