Why yes, you're right, but our friend, the late W. Richard Stevens goes farther and explains that the best method is as following:
#untested code conversion from C sources
exit if fork()!=0;
setsid();
$SIG{'HUP'}='IGNORE';
exit if fork()!=0;
chdir('/'); #prevents path-specific hax
umask(0); #clear file mode creation mask
openlog(...); #standard syslog call
With the second call to fork, we are guaranteed that the child is not a session leader and therefore cannot acquire a controlling terminal. We ignore SIGHUP since the session leader is soon to be terminated. Just an expansion on what you said. I certainly admire and trust the late Mr. Stevens very much!
AgentM Systems nor Nasca Enterprises nor
Bone::Easy nor Macperl is responsible for the
comments made by
AgentM. Remember, you can build any logical system with NOR.