in reply to how to create independent process?

You should fork twice. Have the new process run in the grandchild process, and have the middle process exit.

You'll also want to call setsid, as you did, and probably close open file descriptors, especially if they're to a Web client or a terminal. There are some other steps that may also be useful, depending on what the process will be doing and how long it's going to run.

Proc::Daemon wraps these all up into one easy function, and I'd be inclined to use that.