Remove use of global variable
Move many common functions to a common library

And add stupid wrappers for rad_fork() and rad_waitpid()
We can go fix those later...