throw in a waitpid to avoid race conditions in removal of tmp directory