daemonize a process using ksh

I'm trying to create daemon processes with ksh as follows:

function start 
{
   # start script as co-process and pass an argument
   ./1.ksh $1 |&

   # print pid
   print $!
   
   # move the file descriptors of the co-process to 4 and 5 
   exec 4>&p
   exec 5<&p

   # then close them
   exec 4>&-
   exec 5<&-
}


for server in $servers
do
   start "arg1"
done

  

If script 1.ksh only contains a sleep, then it works. But if I have multiple statements, several ssh calls that take a while (>10min) for example, than the 1.ksh scripts just exits without finishing. This happens shortly after the calling script has finished. If I keep the calling script open they finish correctly. After the child scripts have finshed the calling script also finishes.I added the following after the call to the start routine:

while read -ru5 
do
   print -r $line
done

(and I commented out the closing of the file descriptors)

than it works. I want the 1.ksh processes to become daemon processes and finish and I want the calling script to exit.

I run it on a SunOS 5.8 server with ksh 88.

That won't daemonize anything. Put a command "ps -f > /tmp/ps.out" in the script you think is a daemon. Look at the output. See ? in the TTY field? If not, the script is not a daemon. That is the definition of a daemon.. no controling terminal.

To daemonize ksh.1 do:
echo /path/to/ksh.1 | at now