Fix bug when spawning process in background