IPC-Manager
view release on metacpan or search on metacpan
lib/IPC/Manager/Service/State.pm view on Meta::CPAN
my $params = IPC::Manager::Serializer::JSON->deserialize($json);
my $exec = delete $params->{exec} // {};
$params->{orig_io} = {
stderr => clone_io('>&', \*STDERR),
stdout => clone_io('>&', \*STDOUT),
stdin => clone_io('<&', \*STDIN),
};
my $svc_class = require_mod($params->{class} // 'IPC::Manager::Service');
my $new_inst = $svc_class->new(%$params);
my $exit;
my $code = sub { _ipcm_service(%$params, new_inst => $new_inst); $exit = 0 };
if ($exec->{stay_in_begin}) {
$exit = 255;
$_post_exec_run = sub { $exit };
$code->();
}
lib/IPC/Manager/Service/State.pm view on Meta::CPAN
require IPC::Manager;
$handle_params->{spawn} = IPC::Manager::ipcm_spawn();
$params{ipcm_info} = $handle_params->{spawn}->info;
$params{watch_pids} = [$$];
}
else {
croak "Cannot be called in void context without providing 'ipcm_info'";
}
}
my $class = require_mod($params{class} // 'IPC::Manager::Service');
croak "'$class' does not implement the 'IPC::Manager::Role::Service' role"
unless $skip_role_checks || Role::Tiny::does_role($class, 'IPC::Manager::Role::Service');
my $new_inst = $class->new(%params);
$new_inst->pre_fork_hook();
$exec->{json} = IPC::Manager::Serializer::JSON->serialize(\%params)
if $exec;
lib/IPC/Manager/Util.pm view on Meta::CPAN
Returns true if the L<Linux::Inotify2> module is available and supports the
C<fh> method.
This can be used as a constant.
=item $bool = USE_IO_SELECT()
Returns true if the L<IO::Select> module is available.
=item $mod = require_mod($module)
Loads a module by name. Converts C<::> to C</> and appends C<.pm>.
Returns the original input.
=item $val = pid_is_running($pid)
Checks if a PID is running.
returns 1 if the process is running and we have permissions.
t/unit/Util.t view on Meta::CPAN
like($val, qr/^[01]$/, "value is 0 or 1");
};
subtest 'USE_INOTIFY is constant' => sub {
my $val = USE_INOTIFY();
ok(defined $val, "USE_INOTIFY returns a value");
like($val, qr/^[01]$/, "value is 0 or 1");
};
subtest 'require_mod loads a module' => sub {
my $mod = require_mod('File::Spec');
is($mod, 'File::Spec', "returns the module name");
ok(File::Spec->can('catfile'), "module is loaded");
};
subtest 'require_mod dies on bad module' => sub {
ok(dies { require_mod('This::Module::Does::Not::Exist::ZZZZZ') }, "dies on nonexistent module");
};
subtest 'pid_is_running - current process' => sub {
is(pid_is_running($$), 1, "current process is running");
( run in 1.132 second using v1.01-cache-2.11-cpan-39bf76dae61 )