cc: [email protected]
Subject: Re: [ast-users] KSH trap segfault question?
--------
> Not sure if this is the correct mailing list for my question, but why does
> this
> cause KSH to segfault?
>
> On ubuntu as a normal user:
> $ function hist {
> > cmd=$(fc -ln -0)
> > print $cmd
> > }
>
> $ trap hist DEBUG
> $ w
> Segmentation faul
>
> On Solaris 10 as a normal user:
> $ function hist {
> > cmd=$(fc -ln -0)
> > print $cmd
> > }
> $ trap hist DEBUG
> trap hist DEBUG
>
> $ ps -ef|grep root|wc -l
> ps -ef|grep root|wc -l
> Segmentation Fault (core dumped)
> -bash-3.00$
The problem is that fc is a preset alias to hist, so that function hist
becomes a recursive function without limit. This should have reported
hist: recursion too deep
but because of a bug, it core dumped instead. I will fix this bug.
If you change your hist function to
function hist
{
cmd=$(command fc -ln -0)
print "$cmd"
}
it will execute the builtin version of hist rather than the function.
David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users