in reply to Re^5: run a background process
in thread run a background process

It's ok, problem solved. I just needed to close stdin and stdout for the cgi stuff to end.

And had to use 'setsid' or the program dies whenever the web server goes down.