Stevens recommends the following four steps: 1) fork 2) call setsid() 3) set SIGHUP to SIG_IGN 4) fork again (He also recommends setting the umask to 0, which I don't think is ever a good idea.) At this point you could fix up I/O as required and then exec your 'ordinary' program. The purpose of the double-fork hack is to stop any future opens of terminal devices making the opened device become the controlling terminal for the daemon. (Why is a daemon having a controlling terminal bad? AIUI the problem is that you risk getting SIGTTIN and SIGTTOU signals when you don't want them, but I'm not an expert on job control.) In this model SIGHUP must be ignored as the child gets a SIGHUP when the parent terminates. You could use a pipe to wait for the parent to finish and then set SIGHUP to something more sensible. There are two other ways to do this - never open a terminal device, or always use O_NOCTTY when opening terminal devices. If you use either of these approaches, it should be safe to miss out the SIGHUP setting and the second fork. Since my daemon programs don't usually need to open tty devices, I've never really been bitten. When they do, I use O_NOCTTY. But you may not be able to do this if you're trying to use a pre-existing program. You can do all of the above in C (and indeed the BSD-derived daemon(3) function does it for you) or Perl. Actually at least on Linux there is a program called setsid, which means you can probably do it in shell too, though it might not be portable.