forking process and gracefully shutdown process to avoid memory leaks