Script causing multi forked porcess - not sure why ?

Hi,

I am facing a queer situation, when i run the below script it starts up multiple forked process and hangs the unix server , we had to reboot the server once. Can someone pls help me understand why the script is causing multiple processes to start . If i run ps -ef rename.sh , after i start it and even cancel it (ctrl+c) still i see numerous multiple processes starting

Script name: rename.sh

#!/bin/sh
(
echo "Script `$basename $0` started at `date`"
echo " "
echo "Merging files A and B at `date`"
## merge 1
merge_files.ksh /dummy/test/files file_list_Atxt N N file_list_A.txt
echo "Status (file_list_A) = $?"
echo " "
merge_files.ksh /dummy/test/files file_list_B
txt N N file_list_B.txt
echo "Status (file_list_B) = $?"
#
echo " "
#
echo "Merging files C and D at `date`"
## Merge 2
merge_files.ksh /dummy/test/files file_list_Ctxt Y N file_list_C.txt
echo "Status (file_list_C) = $?"
echo " "
merge_files.ksh /dummy/test/files file_list_D
txt Y N file_list_D.txt
echo "Status (file_list_D) = $?"
echo " "
echo "Merging of files Done at `date`"
echo "-----------------------------------------------------------"
) >> log_file.log

above script when i run seems to go in loops and forks out multiple porcesses quite fast. The embedded script "merge_files.ksh" which actually merges the files is fine as it runs perfectly fine independently with NO issues at all. The embedded merge_files.ksh takes 5 parameters (as can be seen above when calling it) - file dir path, file pattern name, header flag (Y if header is there and N if not), Footer flag (same as header flag, Y and N), final name of then merged file.

can someone pls guie me as to why the above script is going in loops and forking multiple processes ?

Hard to say why without knowing the contents of the script being called within rename ... You could run the rename script with

sh -x rename.sh

to see whats going on during execution, it will not however show inside of the script being called or any functions in place (which i see you have none in the parent script)

What version of unix is this your running ? as under Solaris

ps -ef rename.sh

is an invalid command on my box id need a |grep in there for it to work ....

thx for the quick reply, sorry it was a typo, it shd be ps -ef | grep -c rename.sh , and i could see thousands of such processes,

i did try running in sh -x mode but it would not give any output but just hang and after i press ctrl + c it would take time to come out but i guess would not be properly killed.
i did check the logs and it shows that the script goes in loops and starts multiple processes of itself.