The previous guru's are quite correct.
I might even suggest that you forget about fork(), wait(),
SIGCHLD, etc. and just launch 5 different instances of the
same program with say a file name as an argument...
#!/bin/ksh
myprog file1 > /tmp/file1.$$ &
kid1pid=$!
myprog file2 > /tmp/file2.$$ &
kid2pid=$!
....
myprog file5 > /tmp/file3.$$ &
kid5pid=$!
# at this point you wait on the kids
wait
# here you can assemble the files...
Cwd=`pwd`
cd /tmp
for i in `ls file?.*`
do
cat $i >> $Cwd/newfile.$$
done
rm -f file?.*
cd $Cwd
exit 0
...so... it ain't pretty, it ain't slick or elegant, hell, it ain't even C
but it is simple and will work by Monday