mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix hang in unsetting functions in subshells (re: dde38782)
This fixes a really stupid bug in my own code for unsetting a function in a subshell. The algorithm for walking through the subshell tree was broken, resulting in an infinite loop if there were multiple levels of subshell. src/cmd/ksh93/bltins/typeset.c: - Correct the subshell function tree walk that deletes functions from zombie parent scopes. src/cmd/ksh93/tests/subshell.sh: - Add a regression test for setting and unsetting identically named functions in multiple levels of subshell. (cherry picked from commit 972a7999c7f16469138daf3d86dfd6c0db3f4879)
This commit is contained in:
parent
1026006db3
commit
759157bdb2
2 changed files with 27 additions and 2 deletions
|
@ -1267,8 +1267,8 @@ static int unall(int argc, char **argv, register Dt_t *troot, Shell_t* shp)
|
|||
* from the main shell scope. So walk though troot's parent views and delete any such zombie
|
||||
* functions. Note that this only works because 'unset -f' now forks if we're in a subshell.
|
||||
*/
|
||||
Dt_t *troottmp;
|
||||
while((troottmp = troot->view) && (np = nv_search(name,troottmp,0)) && is_afunction(np))
|
||||
Dt_t *troottmp = troot;
|
||||
while((troottmp = troottmp->view) && (np = nv_search(name,troottmp,0)) && is_afunction(np))
|
||||
nv_delete(np,troottmp,0);
|
||||
}
|
||||
#if 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue