The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Doit::Fork - run code in another process

SYNOPSIS

    use Doit;
    use Doit::Log;
    sub run_test {
        my(undef, $arg) = @_;
        return "running in process $$ with arg $arg";
    }
    return 1 if caller;
    my $doit = Doit->init;
    $doit->add_component('fork');
    my $fork = $doit->do_fork;
    info $fork->call_with_runner('run_test', 'test argument');

DESCRIPTION

This component provides a function do_fork, which forks a new process and returns a new Doit runner (like "do_ssh_connect" in Doit or "do_sudo" in Doit. This process is capable of running subroutines (using call_with_runner or call), or any other core Doit function.

A possible use case is to have multiple separated processes, but with the ability (unlike with normal forked processes) to call subroutines in these processes with possibly complex arguments and return values.

Note that all communication is still synchronous.

AUTHOR

Slaven Rezic <srezic@cpan.org>

COPYRIGHT

Copyright (c) 2017,2023 Slaven Rezic. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Doit, "fork" in perlfunc