Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Perl Background processes in Windows

by mpeg4codec (Pilgrim)
on Jan 18, 2008 at 22:46 UTC ( #663163=note: print w/ replies, xml ) Need Help??

in reply to Perl Background processes in Windows

The most portable way of doing this that I can think of is to use fork followed by exec. Consider the following:

sub run_in_bg { my $pid = fork; die "Can't fork a new process" unless defined $pid; # child gets PID 0 if ($pid == 0) { exec(@_) || die "Can't exec $_[0]"; } # in case you wanted to use waitpid on it return $pid; }
You'd call this the same way you'd call system, except now it forks a new process before running the first arg.

Comment on Re: Perl Background processes in Windows
Download Code
Replies are listed 'Best First'.
Re^2: Perl Background processes in Windows
by chaos_cat (Scribe) on Jan 18, 2008 at 23:11 UTC
    Be careful with that solution. Fork on windows is emulated using threads, not real processes. See perlfork doc. This may not matter for your application, but you should be aware of it.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2016-02-07 08:40 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (250 votes), past polls