Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: process run in background

by stevieb (Canon)
on Jul 27, 2016 at 11:59 UTC ( [id://1168637]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1168637]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-04-23 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found