Proc::ForkSafe − help make objects fork safe
use
Proc::ForkSafe;
package MyPersistentTCPClient {
sub new {
...
}
sub request {
...
}
}
my $client = Proc::ForkSafe−>wrap(sub {
MyPersistentTCPClient−>new });
my $res = $client−>call(request => @some_argv);
my $pid = fork // die;
if ($pid == 0) {
# in child process, $client will be reinitialized
my $res2 = $client−>call(request => @some_argv);
...
exit;
}
waitpid $pid, 0;
Proc::ForkSafe helps make objects fork safe.
Copyright 2023 Shoichi Kaji <[email protected]>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.