That's not the most straightforward way. Use fork(), daemon(), setsid() or something similar in your program.