I was think perhaps a subprocess so you can waitpid and get the output when it completes.