| 1 | package Proc::Spawner; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # EXPERIMENTAL. Starts child processes with posix_spawn(3), and runs the one event loop that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # reports what happened: a child ended, an fd became readable or writable. Nothing else: what the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # children are connected to, and what to do when one ends, is the business of the caller | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # (Proc::Spawner::Graph, the companion module, keeps that as a graph). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # start(PATH, ARGV, ENVP, FDS, %opt) a pid, or undef with $!; with pidfd => 1 in list context, the pid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # and a pidfd. FDS: { CHILD_FD => PARENT_FD, or [PATH, FLAGS, MODE] opened in the child, or undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # for closed }; an fd not listed is inherited as it is (if it is not close-on-exec). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # %opt: every setting posix_spawn has (glibc 2.39), and umask, unsupported: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # chdir => DIR, fchdir => FD the child's current directory (FD: the parent's fd), set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # before the fds, so FDS paths are relative to it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # sigdefault => [SIGNALS] back to the default action in the child (names or numbers) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # sigmask => [SIGNALS] blocked in the child; default: none | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # pgroup => PGID its process group (0: a new one, led by the child) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # setsid => 1 a new session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # tcsetpgrp => FD its group becomes the terminal's foreground, through FD as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # the child has it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # resetids => 1, sched => [POLICY, PRIORITY], cgroup => FD (a cgroup v2 directory) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # search => 1 look PATH up in the PATH of the parent's %ENV (posix_spawnp) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # pidfd => 1 also a pidfd (pidfd_spawn) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # umask => N posix_spawn has none: set in Perl just around the call, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # bullet-proof only in non-threaded execution (the umask is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # whole process's) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # sigignore => [SIGNALS] ignored in the child | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # rlimit => { NAME => SOFT | [SOFT, HARD] } the child's resource limits (NOFILE, CORE, ...; a number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # or 'unlimited'; undef: as ours) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # nice => INCREMENT as nice(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # posix_spawn has none of these three: they are set right around | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | # the call, in C, and put back (M1, post-0.08); one that could not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # be put back is unsupported (spawn's POD) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # unsupported => { OPTION => 'drop' | 'fail' } passed on to spawn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # on_exit => CODE gets the wait status; undef if other code collected it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # first (finding C2) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # spawn(FILE, ARGV, ENVP, ACTIONS, ATTR, UNSUPPORTED) the raw call, see the POD at the end. Meant to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # have one interface on POSIX and on Windows: it wraps the XSUB __posix_spawn (on Windows: win_spawn.h's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # posix_spawn on CreateProcessW) and does what that lacks around the call ($MISSING, below). UNSUPPORTED | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # (optional): { OPTION => 'drop' | 'fail' }, what a port lacking an option (Windows) does with it; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # options not listed there take %UNSUPPORTED's value, and '*' there covers the rest. It applies here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # too, to the posix_spawn extensions this build's libc lacks (chdir, fchdir, closefrom, tcsetpgrp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # pidfd, cgroup; Makefile.PL compiles a call to each): 'fail' fails with ENOTSUP. EXPERIMENTAL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | # on_read(FD, N, CODE), on_write(FD, BYTES, CODE), defer(CODE, ARGS), poll(), wait_until(CODE), loop() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # the one event loop, Proc::Spawner::Loop (W5, post-0.10: one interface on POSIX and on Windows), under its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # old names; loop() is the loop object (read, write, child, after, pipe, ...: its POD). The rules | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # (decisions R1, D1-D3 of the page "Child Exit Wake-up"): every callback runs from the queue, one at a time, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # never inside a signal or inside another callback; a callback never waits; SIGCHLD is ours only while | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # wait_until runs. Background: the document perl-signals-findings.md. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # Process-wide state flipped for a while, so bullet-proof only in non-threaded execution: the umask, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # around start's call (umask => N); the SIGCHLD action, while wait_until runs (D3). Between waits a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # caller may move things on with poll(), for example from its own deferred SIGCHLD handler, as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # Proc::ShellSpawn does while background jobs remain (K3, the user's choice B, post-0.04). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 536 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 536 | ▶ | use POSIX (); use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 536 | ▶ | use Fcntl qw(F_SETFD FD_CLOEXEC F_GETFL F_SETFL O_NONBLOCK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 536 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 536 | our $VERSION = '0.12'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 536 | require XSLoader; XSLoader::load(__PACKAGE__, $VERSION); # __posix_spawn, fpe_at_exec, chld_to_fd, chld_restore | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 536 | our %UNSUPPORTED = ('*' => 'fail'); # the defaults for spawn's UNSUPPORTED (EXPERIMENTAL: '*' => 'fail') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # ------------------------------------------------------------------ settings the spawn primitive lacks (EXPERIMENTAL, post-0.06) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # $MISSING: a bitmap of the settings the primitive (posix_spawn here; CreateProcessW in a Windows port) does not do itself: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # what this build's libc lacks, plus $ENV{PROC_SPAWNER_MISSING} (names, for tests: the suite runs "as if"). spawn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # does the missing ones in this process, around the call, and undoes them after (bullet-proof only with one thread): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # chdir, fchdir this process changes directory, then comes back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # dup2, close, open, this process arranges its own fds as the child should have them (close: close-on-exec), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # closefrom then puts them back; one missing means all four, and chdir and fchdir too (the order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # sigmask this process's mask, set around the call (the child inherits it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # sigdefault an ignored signal's action set back to the default around the call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # pgroup => PGID (> 0) this process joins the group around the call (the child inherits it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # resetids the effective ids set to the real ones around the call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # search PATH looked up here; pidfd: pidfd_open right after the call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # Not possible so: setsid (no way back), tcsetpgrp and pgroup => 0 (the child's pid is known only after), sched | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # and cgroup (not undone reliably): these are unsupported (drop or fail, as UNSUPPORTED says). While this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # process's fds or directory are changed, every signal is blocked, so no handler of ours sees them; the child's mask | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # is set by the primitive. If sigmask is missing too, signals cannot be blocked without the child inheriting it: then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # a handler that runs in that moment sees the changed fds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # rlimit, sigignore and nice (M1, post-0.08), which POSIX's posix_spawn has no option for, are done by the XSUB itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # right around its call, in C (Spawner.xs, around_parse), so they count as native; not on Windows. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # No posix_spawn at all (M2, post-0.08; Makefile.PL found none, or PROC_SPAWNER_MISSING has 'posix_spawn'), as Run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # 0.06's spawn_nowait: the primitive is __spawn_nowait, fork and exec with nothing in between; where there is no fork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # either (Windows, OS/2, VMS; on Linux in tests, PROC_SPAWNER_MISSING="posix_spawn fork": $PRIMITIVE 'system1') the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # redirections are delegated to Run (0.07; the user, 2026-11-07), whose start() applies them around Perl's own spawn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # system { FILE } 1, ARGV (P_NOWAIT; on Unix Run emulates it by fork and exec) and puts our fds back; chdir and fchdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # are done here. Everything but rlimit, sigignore and nice (fork only) is then missing, and done around the call as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # above. On Windows Perl's spawn passes the child fds 0-2 only, as its standard handles, always in a new process group; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # the arguments go to Perl as they are (its command line does not quote them as the C runtime parses them back: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # ❰BUG❱ in Perl, reported; the tests of exact argv there are TODO until Perl is fixed). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 536 | our @FEATURES = qw(chdir fchdir dup2 close open closefrom tcsetpgrp sigmask sigdefault pgroup setsid resetids sched cgroup pidfd search rlimit sigignore nice); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 536 | our %BIT; @BIT{@FEATURES} = map 1 << $_, 0 .. $#FEATURES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 536 | our %NATIVE = map +($_ => 1), __native(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 536 | our %EMULABLE = map +($_ => 1), qw(chdir fchdir dup2 close open closefrom sigmask sigdefault pgroup resetids search pidfd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 536 | ▶ | my @ASKED = grep length, split /[\s,]+/, $ENV{PROC_SPAWNER_MISSING} // ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{"PROC_SPAWNER_MISSING"} // ""
MC/DC0%0/1
$ENV{"PROC_SPAWNER_MISSING"} // ""
$ENV{"PROC_SPAWNER_MISSING"}
Truth table50%1/2
A
A= $ENV{"PROC_SPAWNER_MISSING"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 536 | ▶ | our $FALLBACK = !$NATIVE{posix_spawn} || grep /^(?:posix_spawn|fork)\z/, @ASKED; # no posix_spawn: __spawn_nowait or system1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
!$Proc::Spawner::NATIVE{'posix_spawn'} || grep(/^(?:posix_spawn|fork)\z/, @ASKED)
MC/DC0%0/2
!$Proc::Spawner::NATIVE{'posix_spawn'} || grep(/^(?:posix_spawn|fork)\z/, @ASKED)
!$Proc::Spawner::NATIVE{'posix_spawn'}
grep(/^(?:posix_spawn|fork)\z/, @ASKED)
Truth table33%1/3
not(A) || B
A= !$Proc::Spawner::NATIVE{'posix_spawn'}B= grep(/^(?:posix_spawn|fork)\z/, @ASKED)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 536 | my $NOFORK = grep $_ eq 'fork', @ASKED; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 536 | our %WINDOWS = ( # Windows only (EXPERIMENTAL, post-0.07): how every child is started (win_spawn.h, WIN_OPT_*) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | new_group => 1, # in a process group of its own: Ctrl-C at the console reaches the parent, not the children | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | kill_with_parent => 1, # in a job object that Windows ends when this process ends, however it ends | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | new_console => 1); # a child with none of fds 0-2 gets a console of its own (as Perl's own spawn does) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 536 | our $WIN = $^O eq 'MSWin32'; # EXPERIMENTAL (post-0.07): no SIGCHLD, no fcntl; the loop's Windows backend (W5, post-0.10): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # Proc::Spawner::Loop::Win32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 536 | my %SIGNUM; @SIGNUM{split ' ', $Config{sig_name}} = split ' ', $Config{sig_num}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 536 | our $DOSISH = $^O =~ /^(?:MSWin32|os2|VMS)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 536 | ▶ | our $PRIMITIVE = !$FALLBACK ? 'posix_spawn' : defined &__spawn_nowait && !$DOSISH && !$NOFORK ? 'fork' : 'system1'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
defined &Proc::Spawner::__spawn_nowait and not $Proc::Spawner::DOSISH and not $NOFORK
defined &Proc::Spawner::__spawn_nowait and not $Proc::Spawner::DOSISH
MC/DC0%0/3
defined &Proc::Spawner::__spawn_nowait and not $Proc::Spawner::DOSISH and not $NOFORK
defined &Proc::Spawner::__spawn_nowait
not $Proc::Spawner::DOSISH
not $NOFORK
Truth table0%0/4
A and not(B) and not(C)
A= defined &Proc::Spawner::__spawn_nowaitB= not $Proc::Spawner::DOSISHC= not $NOFORK
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 536 | ▶ | %NATIVE = $PRIMITIVE eq 'fork' ? (map +($_ => 1), grep $NATIVE{$_}, qw(rlimit sigignore nice)) : () if $FALLBACK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 536 | our $MISSING = 0; $MISSING |= $BIT{$_} for grep !$NATIVE{$_}, @FEATURES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 536 | for (grep !/^(?:posix_spawn|fork)\z/, @ASKED) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | exists $BIT{$_} or die "Proc::Spawner: PROC_SPAWNER_MISSING: unknown setting '$_' (known: posix_spawn fork @FEATURES)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $MISSING |= $BIT{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | ▶ | sub missing { my $m = @_ ? shift : $MISSING; grep $m & $BIT{$_}, @FEATURES } # the names in a bitmap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
missing: called CC=2 SCAR=7.2
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 536 | our %WINJOB = (AS => 'ProcessMemoryLimit', DATA => 'ProcessMemoryLimit', CPU => 'PerProcessUserTimeLimit', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | NPROC => 'ActiveProcessLimit'); # W4's mapping of rlimit (approximate: see the POD) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 536 | my %CLASS_NICE = (idle => 19, below_normal => 5, normal => 0, above_normal => -5, high => -10, realtime => -20); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | ▶ | sub win_job_for_rlimit { # W4: rlimit entries as win_job limits (approximate); also the resources with no counterpart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
win_job_for_rlimit: called CC=10 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | my (%job, @none); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 1 | for (@{+shift}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | ▶ | my ($res, $soft, $hard) = @$_; (my $k = uc($res // '')) =~ s/^RLIMIT_//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$res // ""
MC/DC0%0/1
$res // ""
$res
Truth table50%1/2
A
A= $res
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | ▶ | my ($lim) = grep defined && $_ ne 'unlimited' && $_ ne 'infinity', $soft, $hard; # the one that acts first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
defined $_ && $_ ne 'unlimited' && $_ ne 'infinity'
defined $_ and $_ ne "unlimited"
MC/DC66%2/3
defined $_ && $_ ne 'unlimited' && $_ ne 'infinity'
defined $_
$_ ne "unlimited"
$_ ne 'infinity'
Truth table75%3/4
A and B && C
A= defined $_B= $_ ne "unlimited"C= $_ ne 'infinity'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | ▶ | my $w = $WINJOB{$k} or do { push @none, $k; next }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | ▶ | next unless defined $lim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | $lim *= 10_000_000 if $k eq 'CPU'; # seconds -> 100-ns units | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | ▶ | $job{$w} = defined $job{$w} && $job{$w} < $lim ? $job{$w} : $lim } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $job{$w} and $job{$w} < $lim
MC/DC0%0/2
defined $job{$w} and $job{$w} < $lim
defined $job{$w}
$job{$w} < $lim
Truth table66%2/3
A and B
A= defined $job{$w}B= $job{$w} < $lim
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 1 | (\%job, @none) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 6 | ▶ | sub win_class_for_nice { # W4: a nice increment as a priority class, from ours (approximate; never realtime) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
win_class_for_nice: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 6 | ▶ | my $n = ($CLASS_NICE{defined &__win_priority_class ? __win_priority_class() : 'normal'} // 0) + shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"} // 0
MC/DC0%0/1
$CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"} // 0
$CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"}
Truth table50%1/2
A
A= $CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 6 | ▶ | $n >= 10 ? 'idle' : $n >= 1 ? 'below_normal' : $n == 0 ? 'normal' : $n > -10 ? 'above_normal' : 'high' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 357 | ▶ | sub spawn { # the raw call: the primitive (__posix_spawn, or __spawn_nowait), with what it lacks done around it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=138 SCAR=88.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 357 | my ($file, $argv, $envp, $acts, $attr, $uns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 357 | ▶ | if (!$FALLBACK) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 357 | ▶ | my $winonly = !$WIN && ref $attr eq 'HASH' && grep defined $attr->{$_}, qw(win_priority win_job); # (W4: refused here) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
!$Proc::Spawner::WIN && ref $attr eq 'HASH' && grep(defined($attr->{$_}), ('win_priority', 'win_job'))
not $Proc::Spawner::WIN and ref $attr eq "HASH"
MC/DC33%1/3
!$Proc::Spawner::WIN && ref $attr eq 'HASH' && grep(defined($attr->{$_}), ('win_priority', 'win_job'))
not $Proc::Spawner::WIN
ref $attr eq "HASH"
grep(defined($attr->{$_}), ('win_priority', 'win_job'))
Truth table50%2/4
not(A) and B && C
A= not $Proc::Spawner::WINB= ref $attr eq "HASH"C= grep(defined($attr->{$_}), ('win_priority', 'win_job'))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 357 | ▶ | return __posix_spawn(@_) unless ($MISSING || $winonly) && (!defined $uns || ref $uns eq 'HASH'); # (its errors) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$Proc::Spawner::MISSING || $winonly and !defined($uns) || ref $uns eq "HASH"
$Proc::Spawner::MISSING or $winonly
not defined $uns or ref $uns eq "HASH"
MC/DC25%1/4
$Proc::Spawner::MISSING || $winonly and !defined($uns) || ref $uns eq "HASH"
$Proc::Spawner::MISSING
$winonly
not defined $uns
ref $uns eq "HASH"
Truth table42%3/7
A or B and not(C) or D
A= $Proc::Spawner::MISSINGB= $winonlyC= not defined $unsD= ref $uns eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | ▶ | ref $acts eq 'ARRAY' && (!defined $attr || ref $attr eq 'HASH') or return __posix_spawn(@_) } # its errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $acts eq "ARRAY" and !defined($attr) || ref $attr eq "HASH"
not defined $attr or ref $attr eq "HASH"
MC/DC0%0/3
ref $acts eq "ARRAY" and !defined($attr) || ref $attr eq "HASH"
ref $acts eq "ARRAY"
not defined $attr
ref $attr eq "HASH"
Truth table25%1/4
A and not(B) or C
A= ref $acts eq "ARRAY"B= not defined $attrC= ref $attr eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | else { # the same errors as __posix_spawn's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | !defined $uns || ref $uns eq 'HASH' or die "Proc::Spawner::spawn: unsupported must be a hash reference\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $uns or ref $uns eq "HASH"
MC/DC0%0/2
not defined $uns or ref $uns eq "HASH"
not defined $uns
ref $uns eq "HASH"
Truth table0%0/3
not(A) or B
A= not defined $unsB= ref $uns eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | ref $acts eq 'ARRAY' or die "Proc::Spawner::spawn: actions must be an array reference\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | !defined $attr || ref $attr eq 'HASH' or die "Proc::Spawner::spawn: attr must be a hash reference\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $attr or ref $attr eq "HASH"
MC/DC0%0/2
not defined $attr or ref $attr eq "HASH"
not defined $attr
ref $attr eq "HASH"
Truth table0%0/3
not(A) or B
A= not defined $attrB= ref $attr eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | ref eq 'ARRAY' or die "Proc::Spawner::spawn: an action is not an array reference\n" for @$acts } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | my %m = map +($_ => 1), missing(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | my %at = %{$attr // {}}; my @acts = @$acts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attr // {}
MC/DC0%0/1
$attr // {}
$attr
Truth table50%1/2
A
A= $attr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | my $refuse = sub { # an unsupported setting: true (and $! = ENOTSUP) to fail, false to drop it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | my $n = shift; my $v = ($uns && $uns->{$n}) // $UNSUPPORTED{$n} // $UNSUPPORTED{'*'} // 'fail'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition63%7/11
(($uns && $uns->{$n} // $Proc::Spawner::UNSUPPORTED{$n}) // $Proc::Spawner::UNSUPPORTED{"*"}) // "fail"
($uns && $uns->{$n} // $Proc::Spawner::UNSUPPORTED{$n}) // $Proc::Spawner::UNSUPPORTED{"*"}
$uns && $uns->{$n} // $Proc::Spawner::UNSUPPORTED{$n}
$uns and $uns->{$n}
MC/DC0%0/4
(($uns && $uns->{$n} // $Proc::Spawner::UNSUPPORTED{$n}) // $Proc::Spawner::UNSUPPORTED{"*"}) // "fail"
$uns
$uns->{$n}
$Proc::Spawner::UNSUPPORTED{$n}
$Proc::Spawner::UNSUPPORTED{"*"}
Truth table28%2/7
A and B // C // D
A= $unsB= $uns->{$n}C= $Proc::Spawner::UNSUPPORTED{$n}D= $Proc::Spawner::UNSUPPORTED{"*"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | ▶ | $v eq 'drop' ? 0 : do { $! = POSIX::ENOTSUP(); 1 } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 2 | ▶ | if ($WIN) { # W4 (the user, 2026-11-08: "(c) and (b); (c) beats (b) if present"): nice and rlimit mapped to what Windows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # has per child, approximately; win_priority and win_job, Windows' own settings, exact, win over the mapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ($at{nice}) { $at{win_priority} //= win_class_for_nice($at{nice}) } delete $at{nice}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$at{"win_priority"} //= win_class_for_nice($at{"nice"})
MC/DC0%0/2
$at{"win_priority"} //= win_class_for_nice($at{"nice"})
$at{"win_priority"}
win_class_for_nice($at{"nice"})
Truth table0%0/3
A //= B
A= $at{"win_priority"}B= win_class_for_nice($at{"nice"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if (ref $at{rlimit} eq 'ARRAY' && @{$at{rlimit}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $at{"rlimit"} eq "ARRAY" and @{$at{"rlimit"};}
MC/DC0%0/2
ref $at{"rlimit"} eq "ARRAY" and @{$at{"rlimit"};}
ref $at{"rlimit"} eq "ARRAY"
@{$at{"rlimit"};}
Truth table0%0/3
A and B
A= ref $at{"rlimit"} eq "ARRAY"B= @{$at{"rlimit"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | my ($job, @none) = win_job_for_rlimit($at{rlimit}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | for (@none) { return if $refuse->('rlimit') } # (no Windows counterpart; drop: the rest still mapped) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $at{win_job} = { %$job, %{$at{win_job} // {}} } if %$job } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$at{"win_job"} // {}
MC/DC0%0/1
$at{"win_job"} // {}
$at{"win_job"}
Truth table0%0/2
A
A= $at{"win_job"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | delete $at{rlimit} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | elsif (grep defined $at{$_}, qw(win_priority win_job)) { # Windows' own settings elsewhere | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ▶ | for (qw(win_priority win_job)) { next unless defined $at{$_}; return if $refuse->($_); delete $at{$_} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | if ($WIN && ref $at{sigignore} eq 'ARRAY') { # what a Windows child does anyway (post-0.08): there is no SIGPIPE, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Proc::Spawner::WIN and ref $at{"sigignore"} eq "ARRAY"
MC/DC0%0/2
$Proc::Spawner::WIN and ref $at{"sigignore"} eq "ARRAY"
$Proc::Spawner::WIN
ref $at{"sigignore"} eq "ARRAY"
Truth table33%1/3
A and B
A= $Proc::Spawner::WINB= ref $at{"sigignore"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # Ctrl-C is off in a new process group (Perl's kill INT, GenerateConsoleCtrlEvent, does not reach it either) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | my $group = $PRIMITIVE eq 'system1' || $WINDOWS{new_group} || defined $at{pgroup} && !$at{pgroup}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$Proc::Spawner::PRIMITIVE eq 'system1' || $Proc::Spawner::WINDOWS{'new_group'} || defined $at{'pgroup'} && !$at{'pgroup'}
$Proc::Spawner::PRIMITIVE eq "system1" or $Proc::Spawner::WINDOWS{"new_group"}
defined $at{"pgroup"} and not $at{"pgroup"}
MC/DC0%0/4
$Proc::Spawner::PRIMITIVE eq 'system1' || $Proc::Spawner::WINDOWS{'new_group'} || defined $at{'pgroup'} && !$at{'pgroup'}
$Proc::Spawner::PRIMITIVE eq "system1"
$Proc::Spawner::WINDOWS{"new_group"}
defined $at{"pgroup"}
not $at{"pgroup"}
Truth table0%0/5
A or B || C and not(D)
A= $Proc::Spawner::PRIMITIVE eq "system1"B= $Proc::Spawner::WINDOWS{"new_group"}C= defined $at{"pgroup"}D= not $at{"pgroup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $at{sigignore} = [grep !($_ == $SIGNUM{PIPE} || $group && $_ == $SIGNUM{INT}), @{$at{sigignore}}] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$_ == $SIGNUM{'PIPE'} || $group && $_ == $SIGNUM{'INT'}
$group and $_ == $SIGNUM{"INT"}
MC/DC0%0/3
$_ == $SIGNUM{'PIPE'} || $group && $_ == $SIGNUM{'INT'}
$_ == $SIGNUM{'PIPE'}
$group
$_ == $SIGNUM{"INT"}
Truth table0%0/4
A || B and C
A= $_ == $SIGNUM{'PIPE'}B= $groupC= $_ == $SIGNUM{"INT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | ▶ | if ($PRIMITIVE eq 'system1' && $WIN) { # Perl's own spawn on Windows: what it does anyway, and what it cannot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Proc::Spawner::PRIMITIVE eq "system1" and $Proc::Spawner::WIN
MC/DC0%0/2
$Proc::Spawner::PRIMITIVE eq "system1" and $Proc::Spawner::WIN
$Proc::Spawner::PRIMITIVE eq "system1"
$Proc::Spawner::WIN
Truth table33%1/3
A and B
A= $Proc::Spawner::PRIMITIVE eq "system1"B= $Proc::Spawner::WIN
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | delete @at{qw(sigdefault resetids)}; # nothing is inherited, no set-user-id | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | delete $at{sigmask} if ref $at{sigmask} eq 'ARRAY' && !@{$at{sigmask}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $at{"sigmask"} eq "ARRAY" and not @{$at{"sigmask"};}
MC/DC0%0/2
ref $at{"sigmask"} eq "ARRAY" and not @{$at{"sigmask"};}
ref $at{"sigmask"} eq "ARRAY"
not @{$at{"sigmask"};}
Truth table0%0/3
A and not(B)
A= ref $at{"sigmask"} eq "ARRAY"B= not @{$at{"sigmask"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | delete $at{pgroup} if defined $at{pgroup} && !$at{pgroup}; # always a new group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $at{"pgroup"} and not $at{"pgroup"}
MC/DC0%0/2
defined $at{"pgroup"} and not $at{"pgroup"}
defined $at{"pgroup"}
not $at{"pgroup"}
Truth table0%0/3
A and not(B)
A= defined $at{"pgroup"}B= not $at{"pgroup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | for my $n (qw(sigmask pgroup pidfd)) { next unless defined $at{$n} && $at{$n}; return if $refuse->($n); delete $at{$n} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $at{$n} and $at{$n}
MC/DC0%0/2
defined $at{$n} and $at{$n}
defined $at{$n}
$at{$n}
Truth table0%0/3
A and B
A= defined $at{$n}B= $at{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my @k; # the child sees fds 0-2 only | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | for my $x (@acts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my ($op, @a) = @$x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ($op eq 'close' && $a[0] >= 3) { next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$op eq "close" and $a[0] >= 3
MC/DC0%0/2
$op eq "close" and $a[0] >= 3
$op eq "close"
$a[0] >= 3
Truth table0%0/3
A and B
A= $op eq "close"B= $a[0] >= 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ($op eq 'closefrom') { push @k, map [close => $_], $a[0] .. 2; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if ($op eq 'dup2' && $a[1] >= 3 || $op eq 'open' && $a[0] >= 3 || $op eq 'fchdir') { return if $refuse->($op); next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/12
$op eq "dup2" and $a[1] >= 3 or $op eq "open" and $a[0] >= 3 or $op eq "fchdir"
$op eq "dup2" and $a[1] >= 3 or $op eq "open" and $a[0] >= 3
$op eq "dup2" and $a[1] >= 3
$op eq "open" and $a[0] >= 3
MC/DC0%0/5
$op eq "dup2" and $a[1] >= 3 or $op eq "open" and $a[0] >= 3 or $op eq "fchdir"
$op eq "dup2"
$a[1] >= 3
$op eq "open"
$a[0] >= 3
$op eq "fchdir"
Truth table0%0/11
A and B or C and D or E
A= $op eq "dup2"B= $a[1] >= 3C= $op eq "open"D= $a[0] >= 3E= $op eq "fchdir"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | push @k, $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | @acts = @k } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | ▶ | if (ref $at{sigignore} eq 'ARRAY' && ref $at{sigdefault} eq 'ARRAY') { # ignored and set to the default: which? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $at{"sigignore"} eq "ARRAY" and ref $at{"sigdefault"} eq "ARRAY"
MC/DC0%0/2
ref $at{"sigignore"} eq "ARRAY" and ref $at{"sigdefault"} eq "ARRAY"
ref $at{"sigignore"} eq "ARRAY"
ref $at{"sigdefault"} eq "ARRAY"
Truth table33%1/3
A and B
A= ref $at{"sigignore"} eq "ARRAY"B= ref $at{"sigdefault"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my %d = map +($_ => 1), @{$at{sigdefault}}; if (grep $d{$_}, @{$at{sigignore}}) { $! = POSIX::EINVAL(); return } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if (grep $m{$_}, qw(dup2 close open closefrom)) { $m{$_} = 1 for qw(dup2 close open closefrom chdir fchdir) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | my %given = (setsid => sub { $at{setsid} }, nice => sub { $at{nice} }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | sigignore => sub { ref $at{sigignore} eq 'ARRAY' && @{$at{sigignore}} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 1 | for my $n (qw(setsid sched cgroup rlimit sigignore nice)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 6 | ▶ | next unless $m{$n} && ($given{$n} ? $given{$n}->() : defined $at{$n}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$m{$n} and $given{$n} ? $given{$n}->() : defined $at{$n}
MC/DC0%0/2
$m{$n} and $given{$n} ? $given{$n}->() : defined $at{$n}
$m{$n}
$given{$n} ? $given{$n}->() : defined $at{$n}
Truth table33%1/3
A and B
A= $m{$n}B= $given{$n} ? $given{$n}->() : defined $at{$n}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | return if $refuse->($n); delete $at{$n} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ($m{pgroup} && defined $at{pgroup} && !$at{pgroup}) { return if $refuse->('pgroup'); delete $at{pgroup} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$m{"pgroup"} and defined $at{"pgroup"} and not $at{"pgroup"}
$m{"pgroup"} and defined $at{"pgroup"}
MC/DC0%0/3
$m{"pgroup"} and defined $at{"pgroup"} and not $at{"pgroup"}
$m{"pgroup"}
defined $at{"pgroup"}
not $at{"pgroup"}
Truth table25%1/4
A and B and not(C)
A= $m{"pgroup"}B= defined $at{"pgroup"}C= not $at{"pgroup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | ▶ | if ($m{tcsetpgrp} && grep ref eq 'ARRAY' && ($_->[0] // '') eq 'tcsetpgrp', @acts) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition12%1/8
$m{"tcsetpgrp"} and grep((ref $_ eq "ARRAY" && ($_->[0] // "") eq "tcsetpgrp"), @acts)
ref $_ eq 'ARRAY' && ($_->[0] // '') eq 'tcsetpgrp'
$_->[0] // ""
MC/DC0%0/2
$m{"tcsetpgrp"} and grep((ref $_ eq "ARRAY" && ($_->[0] // "") eq "tcsetpgrp"), @acts)
$m{"tcsetpgrp"}
grep((ref $_ eq "ARRAY" && ($_->[0] // "") eq "tcsetpgrp"), @acts)
MC/DC0%0/2
ref $_ eq 'ARRAY' && ($_->[0] // '') eq 'tcsetpgrp'
ref $_ eq 'ARRAY'
$_->[0]
Truth table33%1/3
A and B
A= $m{"tcsetpgrp"}B= grep((ref $_ eq "ARRAY" && ($_->[0] // "") eq "tcsetpgrp"), @acts)
Truth table0%0/3
A && B
A= ref $_ eq 'ARRAY'B= $_->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | return if $refuse->('tcsetpgrp'); @acts = grep !(ref eq 'ARRAY' && ($_->[0] // '') eq 'tcsetpgrp'), @acts } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
ref $_ eq 'ARRAY' && ($_->[0] // '') eq 'tcsetpgrp'
$_->[0] // ""
MC/DC0%0/2
ref $_ eq 'ARRAY' && ($_->[0] // '') eq 'tcsetpgrp'
ref $_ eq 'ARRAY'
$_->[0]
Truth table0%0/3
A && B
A= ref $_ eq 'ARRAY'B= $_->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | my %kind = (chdir => 'dir', fchdir => 'dir', dup2 => 'fd', close => 'fd', open => 'fd', closefrom => 'fd'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | my (@here, @there); # actions done here (in order), and those left to the primitive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | for my $x (@acts) { my $k = ref $x eq 'ARRAY' ? $x->[0] // '' : ''; if ($m{$k} && $kind{$k}) { push @here, $x } else { push @there, $x } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/5
$x->[0] // ""
$m{$k} and $kind{$k}
MC/DC0%0/1
$x->[0] // ""
$x->[0]
MC/DC0%0/2
$m{$k} and $kind{$k}
$m{$k}
$kind{$k}
Truth table0%0/2
A
A= $x->[0]
Truth table0%0/3
A and B
A= $m{$k}B= $kind{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ▶ | if (@here && @there) { # what is done here happens first: so no action done there may come before one done here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@here and @there
MC/DC0%0/2
@here and @there
@here
@there
Truth table33%1/3
A and B
A= @hereB= @there
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my %pos; @pos{map 0 + $_, @acts} = 0 .. $#acts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | my $first_there = (sort { $a <=> $b } map $pos{0 + $_}, @there)[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | my $last_here = (sort { $b <=> $a } map $pos{0 + $_}, @here)[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ($first_there < $last_here) { $! = POSIX::EINVAL(); return } } # (start() puts chdir first) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if ($FALLBACK && @there) { $! = POSIX::EINVAL(); return } # (an action the emulation does not know) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Proc::Spawner::FALLBACK and @there
MC/DC0%0/2
$Proc::Spawner::FALLBACK and @there
$Proc::Spawner::FALLBACK
@there
Truth table33%1/3
A and B
A= $Proc::Spawner::FALLBACKB= @there
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 1 | ▶ | my $sigmask = $m{sigmask} ? delete $at{sigmask} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | ▶ | my $sigdef = $m{sigdefault} ? delete $at{sigdefault} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | my $pg = $m{pgroup} && defined $at{pgroup} ? delete $at{pgroup} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$m{"pgroup"} and defined $at{"pgroup"}
MC/DC0%0/2
$m{"pgroup"} and defined $at{"pgroup"}
$m{"pgroup"}
defined $at{"pgroup"}
Truth table33%1/3
A and B
A= $m{"pgroup"}B= defined $at{"pgroup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | my $reset = $m{resetids} && delete $at{resetids}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$m{'resetids'} && delete $at{'resetids'}
MC/DC0%0/2
$m{'resetids'} && delete $at{'resetids'}
$m{'resetids'}
delete $at{'resetids'}
Truth table33%1/3
A && B
A= $m{'resetids'}B= delete $at{'resetids'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | my $pidfd = $m{pidfd} && delete $at{pidfd}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$m{'pidfd'} && delete $at{'pidfd'}
MC/DC0%0/2
$m{'pidfd'} && delete $at{'pidfd'}
$m{'pidfd'}
delete $at{'pidfd'}
Truth table33%1/3
A && B
A= $m{'pidfd'}B= delete $at{'pidfd'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | my $search = $m{search} && delete $at{search}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$m{'search'} && delete $at{'search'}
MC/DC0%0/2
$m{'search'} && delete $at{'search'}
$m{'search'}
delete $at{'search'}
Truth table33%1/3
A && B
A= $m{'search'}B= delete $at{'search'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | ▶ | if ($search && !$WIN and $file !~ m{/}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$search and not $Proc::Spawner::WIN and not $file =~ m[/]
$search and not $Proc::Spawner::WIN
MC/DC0%0/3
$search and not $Proc::Spawner::WIN and not $file =~ m[/]
$search
not $Proc::Spawner::WIN
not $file =~ m[/]
Truth table25%1/4
A and not(B) and not(C)
A= $searchB= not $Proc::Spawner::WINC= not $file =~ m[/]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | my ($p) = grep -x && !-d, map +(length ? $_ : '.') . "/$file", path_split($ENV{PATH}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-x $_ && !(-d $_)
MC/DC0%0/2
-x $_ && !(-d $_)
-x $_
!(-d $_)
Truth table0%0/3
A && not(B)
A= -x $_B= !(-d $_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | defined $p or do { $! = POSIX::ENOENT(); return }; $file = $p } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | my @undo; my $err; my @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 1 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | if (!$m{sigmask} && (@here || $sigdef || defined $pg || $reset)) { # no handler of ours while this process is changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%4/12
not $m{"sigmask"} and @here || $sigdef || defined $pg || $reset
@here or $sigdef or defined $pg or $reset
@here or $sigdef or defined $pg
@here or $sigdef
MC/DC0%0/5
not $m{"sigmask"} and @here || $sigdef || defined $pg || $reset
not $m{"sigmask"}
@here
$sigdef
defined $pg
$reset
Truth table16%1/6
not(A) and B or C or D or E
A= not $m{"sigmask"}B= @hereC= $sigdefD= defined $pgE= $reset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my ($all, $old) = (POSIX::SigSet->new, POSIX::SigSet->new); $all->fillset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | POSIX::sigprocmask(POSIX::SIG_BLOCK(), $all, $old); unshift @undo, sub { POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | ▶ | if ($sigmask) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my ($set, $old) = (POSIX::SigSet->new(signums($sigmask)), POSIX::SigSet->new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | POSIX::sigprocmask(POSIX::SIG_SETMASK(), $set, $old) or die $!; unshift @undo, sub { POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | ▶ | for my $sig ($sigdef ? signums($sigdef) : ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $old = POSIX::SigAction->new; POSIX::sigaction($sig, undef, $old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | next unless ($old->{HANDLER} // '') eq 'IGNORE'; # a caught signal is reset by exec anyway | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$old->{"HANDLER"} // ""
MC/DC0%0/1
$old->{"HANDLER"} // ""
$old->{"HANDLER"}
Truth table0%0/2
A
A= $old->{"HANDLER"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | POSIX::sigaction($sig, POSIX::SigAction->new('DEFAULT')) or die $!; unshift @undo, sub { POSIX::sigaction($sig, $old) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | ▶ | if (defined $pg) { my $old = getpgrp; POSIX::setpgid(0, $pg) or die $!; unshift @undo, sub { POSIX::setpgid(0, $old) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.9
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | ▶ | if ($reset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($> != $<) { my $e = $>; $> = $<; $> == $< or die $!; unshift @undo, sub { $> = $e } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my ($eg, $rg) = ((split ' ', $))[0], (split ' ', $()[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ($eg != $rg) { my $o = $); $) = $rg; unshift @undo, sub { $) = $o } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | my $redirs = $PRIMITIVE eq 'system1' ? run_redirs(\@here, \@undo) : do { emulate_actions(\@here, \@undo) if @here; undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | @r = $PRIMITIVE eq 'posix_spawn' ? __posix_spawn($file, $argv, $envp, \@there, \%at, $uns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | ▶ | : $PRIMITIVE eq 'fork' ? __spawn_nowait($file, $argv, $envp, { map +($_ => $at{$_}), grep exists $at{$_}, qw(rlimit sigignore nice) }, $uns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | : system1($file, $argv, $envp, $search, $redirs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | $err = $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if (@r && $pidfd) { my $fd = __pidfd_open($r[0]); push @r, $fd >= 0 ? $fd : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
@r and $pidfd
MC/DC0%0/2
@r and $pidfd
@r
$pidfd
Truth table33%1/3
A and B
A= @rB= $pidfd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | my $died = !$ok && $@ !~ /^Proc::Spawner: errno (\d+)/ && $@; # not ours (Run missing, ...): passed on, after the undo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
!($ok || $@ =~ /^Proc::Spawner: errno (\d+)/) && $@
$ok || $@ =~ /^Proc::Spawner: errno (\d+)/
MC/DC0%0/3
!($ok || $@ =~ /^Proc::Spawner: errno (\d+)/) && $@
$ok
$@ =~ /^Proc::Spawner: errno (\d+)/
$@
Truth table25%1/4
not(A || B) && C
A= $okB= $@ =~ /^Proc::Spawner: errno (\d+)/C= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 1 | ▶ | $err = $@ =~ /^Proc::Spawner: errno (\d+)/ ? $1 : ($! + 0 || POSIX::EINVAL()) unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/2
$! + 0 or 22
MC/DC0%0/1
$! + 0 or 22
$! + 0
Truth table0%0/2
A
A= $! + 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | $_->() for @undo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | die $died if $died; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 1 | ▶ | $! = $err; $ok && @r or return; wantarray ? @r : $r[0] } # (scalar context: the pid, as the XSUB gives it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$ok and @r
MC/DC0%0/2
$ok and @r
$ok
@r
Truth table33%1/3
A and B
A= $okB= @r
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 536 | our $PATH_SEP = $Config{path_sep}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 288 | ▶ | sub path_split { # a PATH value's entries, split at $PATH_SEP (post-0.10: $Config{path_sep}, ';' on Windows). POSIX: an empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path_split: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # entry is the current directory. Windows (as Perl's own win32.c reads PATH): a "quoted" part is taken whole, its quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # dropped (an unclosed one runs to the end); empty entries are dropped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 288 | ▶ | my $p = shift // ''; my $s = quotemeta $PATH_SEP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // ""
MC/DC0%0/1
shift() // ""
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 288 | ▶ | $WIN ? grep(length, map tr/"//dr, $p =~ /((?:"[^"]*(?:"|$)|[^"$s])*)/g) : split /$s/, $p, -1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | sub win_find { # posix_spawnp's lookup on Windows, as win_spawn.h's: a name with no directory through PATH (path_split), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
win_find: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # PATHEXT's extensions before the bare name; a path as it is (relative: to the directory now) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my ($file, $search) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | my @ext = ((grep length, split /;/, $ENV{PATHEXT} // '.COM;.EXE;.BAT;.CMD'), ''); # (PATHEXT: Windows' own, always ';') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{"PATHEXT"} // ".COM;.EXE;.BAT;.CMD"
MC/DC0%0/1
$ENV{"PATHEXT"} // ".COM;.EXE;.BAT;.CMD"
$ENV{"PATHEXT"}
Truth table0%0/2
A
A= $ENV{"PATHEXT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | my @dirs = $search && $file !~ m{[/\\:]} ? path_split($ENV{PATH}) : (''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$search and not $file =~ m[[/\\:]]
MC/DC0%0/2
$search and not $file =~ m[[/\\:]]
$search
not $file =~ m[[/\\:]]
Truth table0%0/3
A and not(B)
A= $searchB= not $file =~ m[[/\\:]]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | for my $d (@dirs) { for my $e (@ext) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | my $p = length $d ? "$d\\$file$e" : "$file$e"; return File::Spec->rel2abs($p) if -f $p && -x _ } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
-f $p and -x _
MC/DC0%0/2
-f $p and -x _
-f $p
-x _
Truth table0%0/3
A and B
A= -f $pB= -x _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub system1 { # the primitive without posix_spawn and fork (M2): Run::start around Perl's own spawn; the pid, or empty with $! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
system1: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my ($file, $argv, $envp, $search, $redirs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | require Run; Run->VERSION('0.07'); # (Run::start with a program, {fd => M}, {close => 1}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | local $Run::Forkless = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ($WIN) { # posix_spawn's meaning of FILE (with search: PATH and PATHEXT), not Perl's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $file = win_find($file, $search) // do { $! = -e $file && !-d _ ? POSIX::EACCES() : POSIX::ENOENT(); return } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
win_find($file, $search) // do {
$! = -e $file && !-d(_) ? 13 : 2;
return
}
-e $file and not -d _
MC/DC0%0/2
win_find($file, $search) // do {
$! = -e $file && !-d(_) ? 13 : 2;
return
}
win_find($file, $search)
do {
$! = -e $file && !-d(_) ? 13 : 2;
return
}
MC/DC0%0/2
-e $file and not -d _
-e $file
not -d _
Truth table0%0/3
A // B
A= win_find($file, $search)B= do {
$! = -e $file && !-d(_) ? 13 : 2;
return
}
Truth table0%0/3
A and not(B)
A= -e $fileB= not -d _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | local %ENV = map { /^([^=]+)=(.*)\z/s ? ($1, $2) : () } @$envp if $envp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # X38 (post-0.10): Perl's spawn on Windows passes the child every inheritable handle, and Perl makes its handles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # inheritable (no close-on-exec by $^F there): our fds from 3 up are made not inheritable for the call, then put back, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # as POSIX has it. Not thread-safe: another thread's spawn meanwhile does not pass these fds either. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | my @off = $WIN ? grep(__fd_cloexec($_) == 0, 3 .. __fd_limit() - 1) : (); __set_cloexec($_, 1) for @off; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my @errs; my $pid = eval { Run::start(1, $argv, $redirs, \@errs, $file) }; my ($died, $err) = ($@, $!); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | __set_cloexec($_, 0) for @off; die $died if $died; $! = $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | $pid or return; $pid } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub run_redirs { # system1 (M2): the fd actions as Run's redirections (Run::start applies them around the call and puts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_redirs: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # our fds back); chdir and fchdir done here, in order, so that an open's relative path is taken from the directory then; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # the way back pushed on @$undo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | my ($acts, $undo) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my (@r, $here, @opened); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | my $die = sub { die "Proc::Spawner: errno " . (0 + $!) . "\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | unshift @$undo, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | close $_ for @opened; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if (defined $here) { if ($WIN) { chdir $here } else { __fchdir($here); POSIX::close($here) } } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | for my $x (@$acts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | my ($op, @a) = @$x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | if ($op eq 'chdir' || $op eq 'fchdir') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition0%0/3
$op eq "chdir" or $op eq "fchdir"
MC/DC0%0/2
$op eq "chdir" or $op eq "fchdir"
$op eq "chdir"
$op eq "fchdir"
Truth table0%0/3
A or B
A= $op eq "chdir"B= $op eq "fchdir"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | $here //= $WIN ? do { require Cwd; Cwd::getcwd() // $die->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
Cwd::getcwd() // &$die()
MC/DC0%0/2
Cwd::getcwd() // &$die()
Cwd::getcwd()
&$die()
Truth table0%0/3
A // B
A= Cwd::getcwd()B= &$die()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | : do { my $h = POSIX::open('.', POSIX::O_RDONLY()); defined $h or $die->(); __set_cloexec($h, 1); $h }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$here //= $Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$h
}
MC/DC0%0/2
$here //= $Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$h
}
$here
$Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$h
}
Truth table0%0/3
A //= B
A= $hereB= $Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$h
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | ($op eq 'chdir' ? chdir $a[0] : __fchdir($a[0])) or $die->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | elsif ($op eq 'dup2') { push @r, $a[1] => { fd => $a[0] } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | elsif ($op eq 'close') { push @r, $a[0] => { close => 1 } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | elsif ($op eq 'open') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sysopen my $fh, $a[1], $a[2], $a[3] // 0666 or $die->(); push @opened, $fh; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$a[3] // 438
MC/DC0%0/1
$a[3] // 438
$a[3]
Truth table0%0/2
A
A= $a[3]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | push @r, $a[0] => { filehandle => $fh, pin => 1 } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | elsif ($op eq 'closefrom') { push @r, map +($_ => { close => 1 }), grep __fd_cloexec($_) == 0, $a[0] .. __fd_limit() - 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | else { $! = POSIX::EINVAL(); $die->() } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | \@r } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | sub emulate_actions { # the file actions, done on this process's own fds in order; the way back pushed on @$undo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emulate_actions: not called CC=35 SCAR=71.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | my ($acts, $undo) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my $top = 10; # above every fd the actions name (not an open's flags or mode) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | for my $x (@$acts) { for (@$x[1 .. ($x->[0] eq 'dup2' ? 2 : 1)]) { $top = $_ + 1 if defined && /^[0-9]+\z/ && $_ >= $top } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
defined $_ and /^[0-9]+\z/ and $_ >= $top
defined $_ and /^[0-9]+\z/
MC/DC0%0/3
defined $_ and /^[0-9]+\z/ and $_ >= $top
defined $_
/^[0-9]+\z/
$_ >= $top
Truth table0%0/4
A and B and C
A= defined $_B= /^[0-9]+\z/C= $_ >= $top
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my (%flag, %save, %ours); # an fd's close-on-exec before (-1: was not open); its contents before (a copy; undef: none) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $die = sub { die "Proc::Spawner: errno " . (0 + $!) . "\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | my $flag_touch = sub { my $fd = shift; $flag{$fd} //= __fd_cloexec($fd) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/3
$flag{$fd} //= __fd_cloexec($fd)
MC/DC0%0/2
$flag{$fd} //= __fd_cloexec($fd)
$flag{$fd}
__fd_cloexec($fd)
Truth table0%0/3
A //= B
A= $flag{$fd}B= __fd_cloexec($fd)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | my $content_touch = sub { my $fd = shift; return if exists $save{$fd}; $flag_touch->($fd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | $save{$fd} = $flag{$fd} >= 0 ? do { my $c = __dup_high($fd, $top + 1); $c >= 0 or $die->(); $ours{$c} = 1; $c } : undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my $here; # this process's directory before | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | unshift @$undo, sub { # contents first, then the flags, then the directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | for my $fd (keys %save) { my $c = $save{$fd}; defined $c ? (POSIX::dup2($c, $fd), POSIX::close($c)) : POSIX::close($fd) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | for my $fd (keys %flag) { __set_cloexec($fd, $flag{$fd}) if $flag{$fd} >= 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ($WIN) { chdir $here if defined $here } # (no directory fds there) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | elsif ($here) { __fchdir($here); POSIX::close($here) } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | for my $x (@$acts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | my ($op, @a) = @$x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if ($op eq 'chdir' || $op eq 'fchdir') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition0%0/3
$op eq "chdir" or $op eq "fchdir"
MC/DC0%0/2
$op eq "chdir" or $op eq "fchdir"
$op eq "chdir"
$op eq "fchdir"
Truth table0%0/3
A or B
A= $op eq "chdir"B= $op eq "fchdir"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | $here //= $WIN ? do { require Cwd; Cwd::getcwd() // $die->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
Cwd::getcwd() // &$die()
MC/DC0%0/2
Cwd::getcwd() // &$die()
Cwd::getcwd()
&$die()
Truth table0%0/3
A // B
A= Cwd::getcwd()B= &$die()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | : do { my $h = POSIX::open('.', POSIX::O_RDONLY()); defined $h or $die->(); __set_cloexec($h, 1); $ours{$h} = 1; $h }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$here //= $Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$ours{$h} = 1;
$h
}
MC/DC0%0/2
$here //= $Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$ours{$h} = 1;
$h
}
$here
$Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$ours{$h} = 1;
$h
}
Truth table0%0/3
A //= B
A= $hereB= $Proc::Spawner::WIN ? do {
require Cwd;
Cwd::getcwd() // &$die()
} : do {
my $h = POSIX::open(".", 0);
defined $h or &$die();
__set_cloexec($h, 1);
$ours{$h} = 1;
$h
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | ($op eq 'chdir' ? chdir $a[0] : __fchdir($a[0])) or $die->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | elsif ($op eq 'dup2') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my ($from, $to) = @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if ($from == $to) { __fd_cloexec($from) >= 0 or do { $! = POSIX::EBADF(); $die->() }; $flag_touch->($to); __set_cloexec($to, 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | else { __fd_cloexec($from) >= 0 or do { $! = POSIX::EBADF(); $die->() }; $content_touch->($to); defined POSIX::dup2($from, $to) or $die->() } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | elsif ($op eq 'close' && $WIN) { $content_touch->($a[0]); POSIX::close($a[0]) if defined $save{$a[0]} } # (fds 0-2: Perl's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$op eq "close" and $Proc::Spawner::WIN
MC/DC0%0/2
$op eq "close" and $Proc::Spawner::WIN
$op eq "close"
$Proc::Spawner::WIN
Truth table0%0/3
A and B
A= $op eq "close"B= $Proc::Spawner::WIN
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # spawn passes the standard handles, inheritable or not) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | elsif ($op eq 'close') { $flag_touch->($a[0]); __set_cloexec($a[0], 1) if __fd_cloexec($a[0]) >= 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | elsif ($op eq 'closefrom') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | for my $fd ($a[0] .. __fd_limit() - 1) { next if $ours{$fd} || __fd_cloexec($fd) < 0; $flag_touch->($fd); __set_cloexec($fd, 1) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ours{$fd} or __fd_cloexec($fd) < 0
MC/DC0%0/2
$ours{$fd} or __fd_cloexec($fd) < 0
$ours{$fd}
__fd_cloexec($fd) < 0
Truth table0%0/3
A or B
A= $ours{$fd}B= __fd_cloexec($fd) < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | elsif ($op eq 'open') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my ($fd, $path, $fl, $mode) = @a; $content_touch->($fd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | my $o = POSIX::open($path, $fl, $mode // 0666); defined $o or $die->(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$mode // 438
MC/DC0%0/1
$mode // 438
$mode
Truth table0%0/2
A
A= $mode
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ($o == $fd) { __set_cloexec($fd, 0) } else { my $r = POSIX::dup2($o, $fd); my $e = $!; POSIX::close($o); defined $r or do { $! = $e; $die->() } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | else { $! = POSIX::EINVAL(); $die->() } } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # The loop is Proc::Spawner::Loop (W5, post-0.10); these are its variables, and the functions below its old names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 536 | ▶ | use Proc::Spawner::Loop (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 536 | our ($TRACE, $CAUSE, $REACTING, $DEPTH); # undef or a code ref given one line per operation; the caller's cause (Graph) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 536 | *TRACE = \$Proc::Spawner::Loop::TRACE; *CAUSE = \$Proc::Spawner::Loop::CAUSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 536 | *REACTING = \$Proc::Spawner::Loop::REACTING; *DEPTH = \$Proc::Spawner::Loop::DEPTH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1003 | ▶ | sub tr_ { $TRACE->(join '', @_) if $TRACE } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tr_: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | # ------------------------------------------------------------------ spawning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 340 | ▶ | sub actions { # the file actions giving a child exactly %$fds, whatever the parent's own fd numbers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
actions: called CC=14 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 340 | my $fds = shift; my @t = sort { $a <=> $b } keys %$fds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 340 | ▶ | my @src = grep defined && !ref, values %$fds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $_ && !ref($_)
MC/DC100%2/2
defined $_ && !ref($_)
defined $_
!ref($_)
Truth table100%3/3
A && not(B)
A= defined $_B= !ref($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 340 | ▶ | my $top = 9; for (@t, @src) { $top = $_ if $_ > $top } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 340 | my (@a, @open, %via, @scratch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 340 | for my $f (@src) { # a source fd the child gets something else on: copy it first | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 262 | ▶ | next if $via{$f} or !exists $fds->{$f} or !ref $fds->{$f} && ($fds->{$f} // -1) == $f; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition90%10/11
$via{$f} or not exists $fds->{$f} or not ref $fds->{$f} and ($fds->{$f} // -1) == $f
$via{$f} or not exists $fds->{$f}
not ref $fds->{$f} and ($fds->{$f} // -1) == $f
$fds->{$f} // -1
MC/DC75%3/4
$via{$f} or not exists $fds->{$f} or not ref $fds->{$f} and ($fds->{$f} // -1) == $f
$via{$f}
not exists $fds->{$f}
not ref $fds->{$f}
$fds->{$f}
Truth table80%4/5
A or not(B) or not(C) and D
A= $via{$f}B= not exists $fds->{$f}C= not ref $fds->{$f}D= $fds->{$f}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 4 | push @a, [dup2 => $f, $via{$f} = ++$top]; push @scratch, $top } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 340 | for my $t (@t) { # dup2 to itself too: it clears close-on-exec | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 267 | ▶ | my $f = $fds->{$t} // next; ref $f ? push @open, [open => $t, @$f] : push @a, [dup2 => $via{$f} // $f, $t] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition80%4/5
$fds->{$t} // (next)
$via{$f} // $f
MC/DC100%1/1
$fds->{$t} // (next)
$fds->{$t}
MC/DC0%0/2
$via{$f} // $f
$via{$f}
$f
Truth table100%2/2
A
A= $fds->{$t}
Truth table66%2/3
A // B
A= $via{$f}B= $f
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 340 | @a, @open, map [close => $_], (grep !defined $fds->{$_}, @t), @scratch } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 681 | ▶ | sub signums { map $SIGNUM{$_} // (/^[0-9]+\z/ ? $_ : die "Proc::Spawner: unknown signal '$_'\n"), @{$_[0] // []} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
signums: called CC=4 SCAR=14.3
Pod
undocumented
Branch: 1 branch
Condition80%4/5
$SIGNUM{$_} // (/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
$_[0] // []
MC/DC0%0/2
$SIGNUM{$_} // (/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
$SIGNUM{$_}
(/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
MC/DC100%1/1
$_[0] // []
$_[0]
Truth table33%1/3
A // B
A= $SIGNUM{$_}B= (/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
Truth table100%2/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 536 | ▶ | my %RLIMIT = defined &__rlimits ? __rlimits() : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | ▶ | sub rlimits { # { NAME => SOFT | [SOFT, HARD] } as spawn's [[RESOURCE, SOFT, HARD], ...]; NAME: NOFILE, RLIMIT_NOFILE or a number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rlimits: called CC=5 SCAR=18.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | my $h = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | map { my ($n, $v) = ($_, $h->{$_}); (my $k = uc $n) =~ s/^RLIMIT_//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | ▶ | my $r = $WIN ? $k : $RLIMIT{$k} // ($n =~ /^[0-9]+\z/ ? $n : die "Proc::Spawner: unknown resource '$n'\n"); # (Windows: the name, W4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$RLIMIT{$k} // ($n =~ /^[0-9]+\z/ ? $n : die("Proc::Spawner: unknown resource '${n}'\n"))
MC/DC0%0/2
$RLIMIT{$k} // ($n =~ /^[0-9]+\z/ ? $n : die("Proc::Spawner: unknown resource '${n}'\n"))
$RLIMIT{$k}
($n =~ /^[0-9]+\z/ ? $n : die("Proc::Spawner: unknown resource '${n}'\n"))
Truth table33%1/3
A // B
A= $RLIMIT{$k}B= ($n =~ /^[0-9]+\z/ ? $n : die("Proc::Spawner: unknown resource '${n}'\n"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | ▶ | [$r, ref $v ? @$v[0, 1] : ($v, undef)] } sort keys %$h } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 340 | ▶ | sub start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=10 SCAR=23.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 340 | my ($path, $argv, $envp, $fds, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | my @a = ((map [$_ => $o{$_}], grep defined $o{$_}, qw(chdir fchdir)), actions($fds), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 340 | ▶ | defined $o{tcsetpgrp} ? [tcsetpgrp => $o{tcsetpgrp}] : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | my %attr = (sigmask => [signums($o{sigmask})], sigdefault => [signums($o{sigdefault})], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 340 | map +($_ => $o{$_}), grep exists $o{$_}, qw(pgroup setsid resetids sched cgroup search pidfd nice win_priority win_job)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 339 | ▶ | $attr{sigignore} = [signums($o{sigignore})] if $o{sigignore}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 339 | ▶ | $attr{rlimit} = [rlimits($o{rlimit})] if $o{rlimit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 339 | ▶ | my $um = defined $o{umask} && umask $o{umask}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $o{'umask'} && umask $o{'umask'}
MC/DC50%1/2
defined $o{'umask'} && umask $o{'umask'}
defined $o{'umask'}
umask $o{'umask'}
Truth table66%2/3
A && B
A= defined $o{'umask'}B= umask $o{'umask'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 339 | my ($pid, $pidfd) = spawn($path, $argv, $envp, \@a, \%attr, $o{unsupported}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 339 | ▶ | { local $!; umask $um if defined $o{umask} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 339 | my $how = join ', ', map "$$_[0] " . join('->', @$_[1 .. $#$_]), @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 339 | ▶ | $pid or return tr_("spawn failed: @$argv: $!"), undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 335 | ▶ | tr_("spawn $pid: $path [@$argv]", @a ? "; $how" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 335 | my $cb = $o{on_exit}; # (Windows: the kept process handle is released once the status is taken, post-0.08) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 335 | ▶ | loop()->child($pid, sub { __win_spawn_forget($pid) if $WIN; $cb->(@_) if $cb }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 335 | ▶ | $o{pidfd} && wantarray ? ($pid, $pidfd) : $pid } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$o{"pidfd"} and wantarray
MC/DC50%1/2
$o{"pidfd"} and wantarray
$o{"pidfd"}
wantarray
Truth table66%2/3
A and B
A= $o{"pidfd"}B= wantarray
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | # ------------------------------------------------------------------ the loop: Proc::Spawner::Loop under its old names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 6604 | ▶ | sub loop { Proc::Spawner::Loop->new } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 3035 | ▶ | sub defer { loop()->defer(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 566 | ▶ | sub wait_until { loop()->wait_until(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_until: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 23 | ▶ | sub poll { loop()->poll } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poll: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub turn { loop()->turn(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
turn: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 1799 | ▶ | sub on_read { my ($fd, $n, $cb) = @_; loop()->read($fd, $n, $cb) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_read: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 845 | ▶ | sub on_write { my ($fd, $bytes, $cb, $chunk) = @_; loop()->write($fd, $bytes, $cb, chunk => $chunk) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_write: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 536 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||