SafeFork.xs

filter: Statementstmt 90.0% 9 / 10 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub n/a Podpod n/a totaltotal 81.2% 13 / 16 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
↑ Summary blib/lib/IPC/SafeFork.pm »
1 #include "EXTERN.h"
2 #include "perl.h"
3 #include "XSUB.h"
4  
5 #include "ppport.h"
6  
7  
8 MODULE = IPC::SafeFork PACKAGE = IPC::SafeFork
9  
10 PROTOTYPES: DISABLE
11  
12 SV *
13 xs_fork()
14 PREINIT:
15 pid_t pid;
16 CODE:
17 2 RETVAL = 0;
18 2 ST(0) = sv_newmortal();
19 /* This is not perfect. A signal might happen in the child between
20 the fork and it being set to zero. However sigprocmask() prevents
21 waitpid() from working.
22 So we going from to many signals in the child to to little.
23 But a "fresh" child is less likely to have a significant signal
24 going on.
25 */
26 2 ▶ PERL_ASYNC_CHECK();
Branch: 1 branch
BranchTrueFalseTotal
PERL_ASYNC_CHECK(); 0 2 2
27 2 pid = PerlProc_fork();
28 2 ▶ if( pid < 0 ) { /* error */
Branch: 1 branch
BranchTrueFalseTotal
if( pid < 0 ) { /* error */ 0 2 2
29 0 ST(0) = &PL_sv_undef;
30 }
31 else {
32 2 ▶ if( pid == 0 ) { /* child */
Branch: 1 branch
BranchTrueFalseTotal
if( pid == 0 ) { /* child */ 1 1 2
33 1 PL_sig_pending = 0;
34 1 memset( PL_psig_pend, 0, SIG_SIZE * sizeof(*PL_psig_pend) );
35 /* Note that this means any signal destined for the child that
36 arrives between the fork() and here is forever lost.
37 */
38 }
39 2 sv_setnv( ST(0), pid );
40 }
↑ Summary blib/lib/IPC/SafeFork.pm »