Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Created attachment 1281557[details]
sample.sh
In previous ksh versions, when exiting the scope of a ksh
(not posix) function, it would restore the trap table of
the "calling context" and if the reason the function exited
was a signal, it would call sh_fault() passing as argument
the signal value.
Newer ksh checks it, but calls kill(getpid(), signal_number)
after restoring the trap table, but only calls for SIGINT and
SIGQUIT.
A quick & dirty way to revert to pre ksh-20120801 behaviour
is:
---8<---
diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.orig ksh-20120801/src/cmd/ksh93/sh/xec.c
--- ksh-20120801/src/cmd/ksh93/sh/xec.c.orig 2017-05-23 10:17:39.026021743 -0300
+++ ksh-20120801/src/cmd/ksh93/sh/xec.c 2017-05-23 10:17:40.876961791 -0300
@@ -3529,7 +3529,7 @@ int sh_funscope(int argn, char *argv[],i
}
if(jmpval)
r=shp->exitval;
- if(r>SH_EXITSIG && ((r&SH_EXITMASK)==SIGINT || ((r&SH_EXITMASK)==SIGQUIT)))
+ if(r>SH_EXITSIG)
kill(getpid(),r&SH_EXITMASK);
if(jmpval > SH_JMPFUN)
{
---8<---
The old way appears to have been more appropriate, but there
must be a reason to only pass SIGINT and SIGQUIT as it is an
explicit patch.
The test case terminates only on SIGINT, and other trapped
signals are ignored, even tough the default action of some of
them is to quit a script, e.g. HUP, SEGV, and TERM (ABRT kills
the sample script).
Comment 9Siteshwar Vashisht
2017-08-24 10:40:14 UTC
Comment on attachment 1317641[details]
Enable signal bubbling in nested function calls
I believe it would be better to just check if
_AST_KSH_SIGNAL_BUBBLE is set, for example, instead of:
+ if(r>SH_EXITSIG && ((r&SH_EXITMASK)==SIGINT || ((r&SH_EXITMASK)==SIGQUIT) || ((tmp=getenv("_AST_KSH_SIGNAL_BUBBLE")) && (*tmp!=0))))
have:
+ if(r>SH_EXITSIG && ((r&SH_EXITMASK)==SIGINT || ((r&SH_EXITMASK)==SIGQUIT) || (tmp=getenv("_AST_KSH_SIGNAL_BUBBLE"))))
otherwise, if it requires a value, to be correct it should also parse the
value, e.g. it would enable if one writes:
_AST_KSH_SIGNAL_BUBBLE=0
_AST_KSH_SIGNAL_BUBBLE=off
_AST_KSH_SIGNAL_BUBBLE=false
so, better to just require it to be set, like POSIXLY_CORRECT, that is off by default, and
enabled if the environment variable is set, regardless of value, if any.
(In reply to Paulo Andrade from comment #12)
> + if(r>SH_EXITSIG && ((r&SH_EXITMASK)==SIGINT || ((r&SH_EXITMASK)==SIGQUIT)
> || (tmp=getenv("_AST_KSH_SIGNAL_BUBBLE"))))
That is exactly what Siteshwar has originally implemented. While reviewing the patch, I asked him to change it such that empty and unset variables are treated equally to avoid confusion :) I understand that you see it exactly oppositely.
Given the fact that both of you prefer ignoring the value, I am stepping back on this. Sorry for the extra iteration!
Comment 16Siteshwar Vashisht
2017-08-24 15:09:29 UTC
Created attachment 1281557 [details] sample.sh In previous ksh versions, when exiting the scope of a ksh (not posix) function, it would restore the trap table of the "calling context" and if the reason the function exited was a signal, it would call sh_fault() passing as argument the signal value. Newer ksh checks it, but calls kill(getpid(), signal_number) after restoring the trap table, but only calls for SIGINT and SIGQUIT. A quick & dirty way to revert to pre ksh-20120801 behaviour is: ---8<--- diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.orig ksh-20120801/src/cmd/ksh93/sh/xec.c --- ksh-20120801/src/cmd/ksh93/sh/xec.c.orig 2017-05-23 10:17:39.026021743 -0300 +++ ksh-20120801/src/cmd/ksh93/sh/xec.c 2017-05-23 10:17:40.876961791 -0300 @@ -3529,7 +3529,7 @@ int sh_funscope(int argn, char *argv[],i } if(jmpval) r=shp->exitval; - if(r>SH_EXITSIG && ((r&SH_EXITMASK)==SIGINT || ((r&SH_EXITMASK)==SIGQUIT))) + if(r>SH_EXITSIG) kill(getpid(),r&SH_EXITMASK); if(jmpval > SH_JMPFUN) { ---8<--- The old way appears to have been more appropriate, but there must be a reason to only pass SIGINT and SIGQUIT as it is an explicit patch. The test case terminates only on SIGINT, and other trapped signals are ignored, even tough the default action of some of them is to quit a script, e.g. HUP, SEGV, and TERM (ABRT kills the sample script).