way to exit a infinite process

There is a sh file called "agg.sh",

this is a kind of negative scenario, this script would fail as expected, but the problem is that after executing the script the following o/p is displayed continuosly without returning the control.We have to press "crtrl+c" to exit the script.

[29f2][error] CalXmlParser cannot open agg2.conf.
./agg.sh: line 9: 10738 Segmentation fault

I need a solution by which we can subsitute "ctrl+c" inside a shell script itself.

It would also be a great help to get a solution that can insert a "ctrl +c" after execution of any script that never returns control to the user unless manually pressing "ctrl +c".

Plz help me anybody.:confused:

man builtins. Search for exit.

That is not after executing the script; that is inside a loop in the script. You probably want to exit the loop if a command inside it fails. For example:

while :
do
   cat xx$(( $RANDOM % 10 )) || break
done

Thanks for the reply,

yes the problem was with the loop,now I have changed it, its working fine now.Thanks once again.