in reply to process run in background

I like Proc::Background for this task, as it is cross-platform (*nix and Windows).

It's as simple as:

my $bg = Proc::Background->new(@cmd_and_args); my $pid = $bg->pid;

I've used it in a more complex way with start/stop/status functionality with run-in-foreground ability, where the server code is in a module: server module (the bg proc is actually created on line 106), and then a script that starts, stops etc the daemon: server control script.

Essentially how it works is that the script is called from the CLI, which in turn executes the module start code, which re-calls the script with a different argument, which calls the listener/network code in the module which is put into the background.