Code Monkey home page Code Monkey logo

Comments (6)

McDutchie avatar McDutchie commented on September 28, 2024 1

It appears that the root cause is probably the fact that ksh only properly disables job control in non-forked/virtual subshells if they are command substitutions. I'm testing a fix for #89 and that fix makes this bug go away as well.

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024 1

This diff fixes it for me. For some reason I can't fathom, sh_fork() did not reset shp->savesig when in a virtual subshell, causing SIGINT to be ignored after running an external command using sh_fork() for the duration of the virtual subshell. The patch does not cause any regression test failures for me, on a ksh compiled with and without -DSHOPT_SPAWN=0.

diff --git a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c
index a6ad507..baa8d6d 100644
--- a/src/cmd/ksh93/sh/xec.c
+++ b/src/cmd/ksh93/sh/xec.c
@@ -2951,13 +2951,10 @@ pid_t sh_fork(Shell_t *shp,int flags, int *jobid)
 	shp->savesig = -1;
 	while(_sh_fork(shp,parent=fork(),flags,jobid) < 0);
 	sh_stats(STAT_FORKS);
-	if(!shp->subshell)
-	{
-		sig = shp->savesig;
-		shp->savesig = 0;
-		if(sig>0)
-			kill(getpid(),sig);
-	}
+	sig = shp->savesig;
+	shp->savesig = 0;
+	if(sig>0)
+		kill(getpid(),sig);
 	job_fork(parent);
 	return(parent);
 }

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024

This bug is not present in ksh2020, which has removed spawnveg.

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024

This probably doesn't need to be a blocking bug now that #79 is fixed.

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024

Actually, after the fix for #79, now this bug still occurs when compiled with SHOPT_SPAWN on, and if the shell is interactive and has job control on:

$ arch/*/bin/ksh -i -c '(/usr/bin/true; while :; do :; done); exit'
^C^C^C^C^C

from ksh.

McDutchie avatar McDutchie commented on September 28, 2024

It appears that the root cause is probably the fact that ksh only properly disables job control in non-forked/virtual subshells if they are command substitutions. I'm testing a fix for #89 and that fix makes this bug go away as well.

Of course it does; the #89 fix makes ksh use sh_ntfork() instead of sh_fork(), where the bug is. So that was a false lead.

from ksh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.