line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Proc::Forkfunc; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
require Exporter; |
5
|
|
|
|
|
|
|
require POSIX; |
6
|
5
|
|
|
5
|
|
2870
|
use Carp; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
715
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
@ISA = (Exporter); |
9
|
|
|
|
|
|
|
@EXPORT = qw(forkfunc); |
10
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
35
|
use vars qw($VERSION); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
375
|
|
12
|
|
|
|
|
|
|
$VERSION = 96.041701; |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
35
|
use strict; |
|
5
|
|
|
|
|
25
|
|
|
5
|
|
|
|
|
1075
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub forkfunc |
17
|
|
|
|
|
|
|
{ |
18
|
14
|
|
|
14
|
0
|
1589006
|
my ($func, @args) = @_; |
19
|
|
|
|
|
|
|
|
20
|
14
|
|
|
|
|
30
|
my $pid; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
{ |
23
|
14
|
100
|
|
|
|
35
|
if ($pid = fork()) { |
|
14
|
50
|
|
|
|
13490
|
|
|
|
0
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# parent |
25
|
10
|
|
|
|
|
628
|
return $pid; |
26
|
|
|
|
|
|
|
} elsif (defined $pid) { |
27
|
|
|
|
|
|
|
# child |
28
|
4
|
|
|
|
|
360
|
&$func(@args); |
29
|
0
|
|
|
|
|
|
croak "call to child returned\n"; |
30
|
|
|
|
|
|
|
} elsif ($! == &POSIX::EAGAIN) { |
31
|
0
|
|
|
|
|
|
my $o0 = $0; |
32
|
0
|
|
|
|
|
|
$0 = "$o0: waiting to fork"; |
33
|
0
|
|
|
|
|
|
sleep 5; |
34
|
0
|
|
|
|
|
|
$0 = $o0; |
35
|
0
|
|
|
|
|
|
redo; |
36
|
|
|
|
|
|
|
} else { |
37
|
0
|
|
|
|
|
|
croak "Can't fork: $!"; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |