1Proc::ForkSafe(3pm) User Contributed Perl Documentation Proc::ForkSafe(3pm)
2
3
4
6 Proc::ForkSafe - help make objects fork safe
7
9 use Proc::ForkSafe;
10
11 package MyPersistentTCPClient {
12 sub new {
13 ...
14 }
15 sub request {
16 ...
17 }
18 }
19
20 my $client = Proc::ForkSafe->wrap(sub { MyPersistentTCPClient->new });
21 my $res = $client->call(request => @some_argv);
22
23 my $pid = fork // die;
24 if ($pid == 0) {
25 # in child process, $client will be reinitialized
26 my $res2 = $client->call(request => @some_argv);
27 ...
28 exit;
29 }
30 waitpid $pid, 0;
31
33 Proc::ForkSafe helps make objects fork safe.
34
36 Copyright 2023 Shoichi Kaji <skaji@cpan.org>
37
38 This library is free software; you can redistribute it and/or modify it
39 under the same terms as Perl itself.
40
41
42
43perl v5.38.0 2023-08-09 Proc::ForkSafe(3pm)