| 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 | 554 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 554 | ▶ | use POSIX (); use File::Spec (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 554 | ▶ | use Fcntl qw(F_SETFD FD_CLOEXEC F_GETFL F_SETFL O_NONBLOCK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 554 | ▶ | use Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 555 | our $VERSION = '0.13'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 555 | require XSLoader; XSLoader::load(__PACKAGE__, $VERSION); # __posix_spawn, fpe_at_exec, chld_to_fd, chld_restore | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 555 | our %UNSUPPORTED = ('*' => 'fail'); # the defaults for spawn's UNSUPPORTED (EXPERIMENTAL: '*' => 'fail') | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # ------------------------------------------------------------------ settings the spawn primitive lacks (EXPERIMENTAL, post-0.06) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # %MISSING: the settings, as its keys, that the primitive (posix_spawn here; CreateProcessW in a Windows port) does not do itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # (JC3, post-0.12: a hash; until then a bitmap, $MISSING, with the table %BIT and the function missing()): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # what this build's libc lacks, plus $ENV{PROC_SPAWNER_MISSING} (names, for tests: the suite runs "as if"). spawn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # does the missing ones in this process, around the call, and undoes them after (bullet-proof only with one thread): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # chdir, fchdir this process changes directory, then comes back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # dup2, close, open, this process arranges its own fds as the child should have them (close: close-on-exec), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # closefrom then puts them back; one missing means all four, and chdir and fchdir too (the order) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # sigmask this process's mask, set around the call (the child inherits it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # sigdefault an ignored signal's action set back to the default around the call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # pgroup => PGID (> 0) this process joins the group around the call (the child inherits it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # resetids the effective ids set to the real ones around the call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # search PATH looked up here; pidfd: pidfd_open right after the call | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # Not possible so: setsid (no way back), tcsetpgrp and pgroup => 0 (the child's pid is known only after), sched | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # and cgroup (not undone reliably): these are unsupported (drop or fail, as UNSUPPORTED says). While this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # process's fds or directory are changed, every signal is blocked, so no handler of ours sees them; the child's mask | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # is set by the primitive. If sigmask is missing too, signals cannot be blocked without the child inheriting it: then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # a handler that runs in that moment sees the changed fds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # rlimit, sigignore and nice (M1, post-0.08), which POSIX's posix_spawn has no option for, are done by the XSUB itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # right around its call, in C (Spawner.xs, around_parse), so they count as native; not on Windows. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # No posix_spawn at all (M2, post-0.08; Makefile.PL found none, or PROC_SPAWNER_MISSING has 'posix_spawn'), as Run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # 0.06's spawn_nowait: the primitive is __spawn_nowait, fork and exec with nothing in between; where there is no fork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # either (Windows, OS/2, VMS; on Linux in tests, PROC_SPAWNER_MISSING="posix_spawn fork": $PRIMITIVE 'system1') the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # redirections are delegated to Run (0.07; the user, 2026-11-07), whose start() applies them around Perl's own spawn, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # system { FILE } 1, ARGV (P_NOWAIT; on Unix Run emulates it by fork and exec) and puts our fds back; chdir and fchdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # are done here. Everything but rlimit, sigignore and nice (fork only) is then missing, and done around the call as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # above. On Windows Perl's spawn passes the child fds 0-2 only, as its standard handles, in a new process group (as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # every child Perl does not wait for: system 1, ...); the arguments go to Perl as they are (its command line does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # quote them as the C runtime parses them back: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # ❰BUG❱ in Perl, drafted in doc/perl-win32-system-bugs.md, not yet filed; the tests of exact argv there are TODO until Perl is fixed). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 555 | our @FEATURES = qw(chdir fchdir dup2 close open closefrom tcsetpgrp sigmask sigdefault pgroup setsid resetids sched cgroup pidfd | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | search rlimit sigignore nice); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 555 | our %NATIVE = map +($_ => 1), __native(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 555 | our %EMULABLE = map +($_ => 1), qw(chdir fchdir dup2 close open closefrom sigmask sigdefault pgroup resetids search pidfd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 555 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 554 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 554 | my $NOFORK = grep $_ eq 'fork', @ASKED; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 554 | our %WINDOWS = ( # Windows only (EXPERIMENTAL, post-0.07): how every child is started (win_spawn.h, WIN_OPT_*) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | new_group => 'auto', # a process group of its own, where Windows turns Ctrl-C off: 'auto' (post-0.12, the user's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # W7): for a child that would have SIGINT ignored (win_new_group); 1 always; 0 never | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | kill_with_parent => 0, # 1: in a job object that Windows ends when this process ends, however it ends (off since | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # post-0.12, the user's W6: as Perl's own spawn; the POD says what that costs) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | new_console => 1); # a child with none of fds 0-2 gets a console of its own (as Perl's own spawn does) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 554 | our $WIN = $^O eq 'MSWin32'; # EXPERIMENTAL (post-0.07): no SIGCHLD, no fcntl; the loop's Windows backend (W5, post-0.10): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # Proc::Spawner::Loop::Win32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 554 | our (%SIGNUM, %SIGNAME); # signal names => numbers, and numbers => names (of several names for one number, the last in | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 554 | @SIGNUM{split ' ', $Config{sig_name}} = split ' ', $Config{sig_num}; # %Config's list); Proc::ShellSpawn::Large uses | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 554 | @SIGNAME{split ' ', $Config{sig_num}} = split ' ', $Config{sig_name}; # both (JH3, part e) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 554 | our $DOSISH = $^O =~ /^(?:MSWin32|os2|VMS)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 554 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 554 | ▶ | %NATIVE = $PRIMITIVE eq 'fork' ? (map +($_ => 1), grep $NATIVE{$_}, qw(rlimit sigignore nice)) : () if $FALLBACK; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 554 | our %MISSING = map +($_ => 1), grep !$NATIVE{$_}, @FEATURES; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 554 | for my $s (grep !/^(?:posix_spawn|fork)\z/, @ASKED) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | grep $_ eq $s, @FEATURES or die "Proc::Spawner: PROC_SPAWNER_MISSING: unknown setting '$s' (known: posix_spawn fork @FEATURES)\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $MISSING{$s} = 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 554 | our %WINJOB = (AS => 'ProcessMemoryLimit', DATA => 'ProcessMemoryLimit', CPU => 'PerProcessUserTimeLimit', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | NPROC => 'ActiveProcessLimit'); # W4's mapping of rlimit (approximate: see the POD) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Windows' priority classes and nice values, both ways, as Cygwin maps them (winsup/cygwin/miscfuncs.cc, winprio_to_nice | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # and nice_to_winprio; post-0.12, the user, 2026-11-15): a class's nice value, and the class of the nice values 12..19, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # 4..11, -4..3, -12..-5, -19..-13, -20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 554 | our %CLASS_NICE = (idle => 16, below_normal => 8, normal => 0, above_normal => -8, high => -16, realtime => -20); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 17 | ▶ | sub class_of_nice { my $n = shift; $n >= 12 ? 'idle' : $n >= 4 ? 'below_normal' : $n >= -4 ? 'normal' : $n >= -12 ? 'above_normal' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
class_of_nice: called CC=6 SCAR=17.9
Pod
undocumented
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | : $n > -20 ? 'high' : 'realtime' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 1 | my (%job, @none); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | for (@{+shift}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 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'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | ▶ | my $w = $WINJOB{$k} or do { push @none, $k; next }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | ▶ | next unless defined $lim; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 4 | ▶ | $lim *= 10_000_000 if $k eq 'CPU'; # seconds -> 100-ns units | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | (\%job, @none) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 10 | ▶ | 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=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 10 | ▶ | my $c = class_of_nice(($CLASS_NICE{defined &__win_priority_class ? __win_priority_class() : 'normal'} // 0) + shift); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$Proc::Spawner::CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"} // 0
MC/DC0%0/1
$Proc::Spawner::CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"} // 0
$Proc::Spawner::CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"}
Truth table50%1/2
A
A= $Proc::Spawner::CLASS_NICE{defined &Proc::Spawner::__win_priority_class ? __win_priority_class() : "normal"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | ▶ | $c eq 'realtime' ? 'high' : $c } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | ▶ | sub nice_for_win_class { # (post-0.12) a priority class elsewhere: the nice increment from ours to the class's value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nice_for_win_class: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | ▶ | my $c = shift; defined $c && exists $CLASS_NICE{$c} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $c and exists $Proc::Spawner::CLASS_NICE{$c}
MC/DC50%1/2
defined $c and exists $Proc::Spawner::CLASS_NICE{$c}
defined $c
exists $Proc::Spawner::CLASS_NICE{$c}
Truth table66%2/3
A and B
A= defined $cB= exists $Proc::Spawner::CLASS_NICE{$c}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | $CLASS_NICE{$c} - getpriority(0, 0) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 371 | ▶ | sub spawn { # the raw call: the primitive (__posix_spawn, or __spawn_nowait), with what it lacks done around it. In five | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=61 SCAR=67.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # steps (JH5 b, post-0.12): the arguments checked, Windows' settings mapped, what is not supported refused or dropped, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # file actions sorted into those done here and those left to the primitive, then the call with the changes around it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 371 | my ($file, $argv, $envp, $acts, $attr, $uns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 371 | ▶ | return __posix_spawn(@_) if spawn_args(@_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | my %m = %MISSING; # (a copy: below, one missing fd action makes the other fd actions missing too) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | ▶ | my %at = %{$attr // {}}; my @acts = @$acts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attr // {}
MC/DC0%0/1
$attr // {}
$attr
Truth table50%1/2
A
A= $attr
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 8 | ▶ | my $refuse = sub { # an unsupported setting: true (and $! = ENOTSUP) to fail, false to drop it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | my $n = shift; my $v = ($uns && $uns->{$n}) // $UNSUPPORTED{$n} // $UNSUPPORTED{'*'} // 'fail'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition36%4/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 table14%1/7
A and B // C // D
A= $unsB= $uns->{$n}C= $Proc::Spawner::UNSUPPORTED{$n}D= $Proc::Spawner::UNSUPPORTED{"*"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | $v eq 'drop' ? 0 : do { $! = POSIX::ENOTSUP(); 1 } }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | ▶ | spawn_windows(\%at, $refuse) && spawn_unsupported(\%at, \@acts, \%m, $refuse) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
spawn_windows(\%at, $refuse) and spawn_unsupported(\%at, \@acts, \%m, $refuse)
MC/DC50%1/2
spawn_windows(\%at, $refuse) and spawn_unsupported(\%at, \@acts, \%m, $refuse)
spawn_windows(\%at, $refuse)
spawn_unsupported(\%at, \@acts, \%m, $refuse)
Truth table66%2/3
A and B
A= spawn_windows(\%at, $refuse)B= spawn_unsupported(\%at, \@acts, \%m, $refuse)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | ▶ | my ($here, $there) = spawn_sort_actions(\@acts, \%m) or return; my @here = @$here; my @there = @$there; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | ▶ | my $sigmask = $m{sigmask} ? delete $at{sigmask} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | my $sigdef = $m{sigdefault} ? delete $at{sigdefault} : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | ▶ | if ($search && $WIN && $PRIMITIVE ne 'system1') { # X64: posix_spawnp's lookup on Windows, as system1 does it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
$search and $Proc::Spawner::WIN and $Proc::Spawner::PRIMITIVE ne "system1"
$search and $Proc::Spawner::WIN
MC/DC0%0/3
$search and $Proc::Spawner::WIN and $Proc::Spawner::PRIMITIVE ne "system1"
$search
$Proc::Spawner::WIN
$Proc::Spawner::PRIMITIVE ne "system1"
Truth table25%1/4
A and B and C
A= $searchB= $Proc::Spawner::WINC= $Proc::Spawner::PRIMITIVE ne "system1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $file = win_find($file, 1) // do { $! = -e $file && !-d _ ? POSIX::EACCES() : POSIX::ENOENT(); return } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
win_find($file, 1) // do {
$! = -e $file && !-d(_) ? 13 : 2;
return
}
-e $file and not -d _
MC/DC0%0/2
win_find($file, 1) // do {
$! = -e $file && !-d(_) ? 13 : 2;
return
}
win_find($file, 1)
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, 1)B= do {
$! = -e $file && !-d(_) ? 13 : 2;
return
}
Truth table0%0/3
A and not(B)
A= -e $fileB= not -d _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | ▶ | elsif ($search && !$WIN and $file !~ m{/}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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[/]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 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 $_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | defined $p or do { $! = POSIX::ENOENT(); return }; $file = $p } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | my @undo; my $err; my @r; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 1 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | if (!$WIN && !$m{sigmask} && (@here || $sigdef || defined $pg || $reset)) { # no handler of ours while this process is changed (X64: not on Windows) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%5/15
not $Proc::Spawner::WIN || $m{"sigmask"} and @here || $sigdef || defined $pg || $reset
$Proc::Spawner::WIN || $m{'sigmask'}
@here or $sigdef or defined $pg or $reset
@here or $sigdef or defined $pg
@here or $sigdef
MC/DC0%0/6
not $Proc::Spawner::WIN || $m{"sigmask"} and @here || $sigdef || defined $pg || $reset
$Proc::Spawner::WIN
$m{'sigmask'}
@here
$sigdef
defined $pg
$reset
Truth table14%1/7
not(A || B) and C or D or E or F
A= $Proc::Spawner::WINB= $m{'sigmask'}C= @hereD= $sigdefE= defined $pgF= $reset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my ($all, $old) = (POSIX::SigSet->new, POSIX::SigSet->new); $all->fillset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | if ($sigmask) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my ($set, $old) = (POSIX::SigSet->new(signums($sigmask)), POSIX::SigSet->new); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | POSIX::sigprocmask(POSIX::SIG_SETMASK(), $set, $old) or die $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | unshift @undo, sub { POSIX::sigprocmask(POSIX::SIG_SETMASK(), $old) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | ▶ | for my $sig ($sigdef ? signums($sigdef) : ()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | my $old = POSIX::SigAction->new; POSIX::sigaction($sig, undef, $old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | if ($reset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ($> != $<) { my $e = $>; $> = $<; $> == $< or die $!; unshift @undo, sub { $> = $e } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my ($eg, $rg) = ((split ' ', $))[0], (split ' ', $()[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if ($eg != $rg) { my $o = $); $) = $rg; unshift @undo, sub { $) = $o } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 1 | ▶ | my $redirs = $PRIMITIVE eq 'system1' ? run_redirs(\@here, \@undo) : do { emulate_actions(\@here, \@undo) if @here; undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | @r = $PRIMITIVE eq 'posix_spawn' ? __posix_spawn($file, $argv, $envp, \@there, \%at, $uns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | : $PRIMITIVE eq 'fork' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | ▶ | ? __spawn_nowait($file, $argv, $envp, { map +($_ => $at{$_}), grep exists $at{$_}, qw(rlimit sigignore nice) }, $uns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | : system1($file, $argv, $envp, $search, $redirs); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | $err = $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 1 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 8 | 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 8 | ▶ | 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= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 1 | $_->() for @undo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | die $died if $died; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 371 | ▶ | sub spawn_args { # spawn, step 1: true where __posix_spawn is to be called as it is (nothing to do around it, or arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn_args: called CC=19 SCAR=44.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # it rejects with its own errors); in the fallback, where there is no __posix_spawn, its errors are raised here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 371 | my (undef, undef, undef, $acts, $attr, $uns) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 371 | ▶ | if (!$FALLBACK) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 371 | ▶ | my $winonly = !$WIN && ref $attr eq 'HASH' && grep defined $attr->{$_}, qw(win_priority win_job); # (W4: mapped or 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'))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 371 | ▶ | return 1 unless (%MISSING || $winonly || $WIN) && (!defined $uns || ref $uns eq 'HASH'); # (its | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%8/12
%Proc::Spawner::MISSING || $winonly || $Proc::Spawner::WIN and !defined($uns) || ref $uns eq "HASH"
%Proc::Spawner::MISSING or $winonly or $Proc::Spawner::WIN
%Proc::Spawner::MISSING or $winonly
not defined $uns or ref $uns eq "HASH"
MC/DC20%1/5
%Proc::Spawner::MISSING || $winonly || $Proc::Spawner::WIN and !defined($uns) || ref $uns eq "HASH"
%Proc::Spawner::MISSING
$winonly
$Proc::Spawner::WIN
not defined $uns
ref $uns eq "HASH"
Truth table30%3/10
A or B or C and not(D) or E
A= %Proc::Spawner::MISSINGB= $winonlyC= $Proc::Spawner::WIND= not defined $unsE= ref $uns eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # errors; Windows: win_new_group below) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | ▶ | ref $acts eq 'ARRAY' && (!defined $attr || ref $attr eq 'HASH') or return 1 } # 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | else { # the same errors as __posix_spawn's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | ref $acts eq 'ARRAY' or die "Proc::Spawner::spawn: actions must be an array reference\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | ▶ | ref eq 'ARRAY' or die "Proc::Spawner::spawn: an action is not an array reference\n" for @$acts } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | 0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | sub spawn_windows { # spawn, step 2: Windows' settings (%$at changed); false, with $!, to fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn_windows: called CC=25 SCAR=54.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 2 | my ($atr, $refuse) = @_; my %at = %$atr; # (a copy, put back at the end: the lines below as they were in spawn) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # has per child, approximately; win_priority and win_job, Windows' own settings, exact, win over the mapping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 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"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 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"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my ($job, @none) = win_job_for_rlimit($at{rlimit}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | for (@none) { return if $refuse->('rlimit') } # (no Windows counterpart; drop: the rest still mapped) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | delete $at{rlimit} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | elsif (grep defined $at{$_}, qw(win_priority win_job)) { # Windows' own settings elsewhere: a priority class is mapped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | ▶ | if (defined(my $c = delete $at{win_priority})) { # to its nice value where nice is not given (post-0.12, the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | my $inc = nice_for_win_class($c); # user, 2026-11-15); nice, the native setting, wins | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 1 | ▶ | defined $inc or return do { $! = POSIX::EINVAL(); undef }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | $at{nice} //= $inc } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$at{"nice"} //= $inc
MC/DC0%0/2
$at{"nice"} //= $inc
$at{"nice"}
$inc
Truth table0%0/3
A //= B
A= $at{"nice"}B= $inc
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 1 | ▶ | if (defined $at{win_job}) { return if $refuse->('win_job'); delete $at{win_job} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 1 | ▶ | $at{win_new_group} = win_new_group(\%at) if $WIN && $PRIMITIVE ne 'system1'; # (W7; read by the XSUB) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Proc::Spawner::WIN and $Proc::Spawner::PRIMITIVE ne "system1"
MC/DC0%0/2
$Proc::Spawner::WIN and $Proc::Spawner::PRIMITIVE ne "system1"
$Proc::Spawner::WIN
$Proc::Spawner::PRIMITIVE ne "system1"
Truth table33%1/3
A and B
A= $Proc::Spawner::WINB= $Proc::Spawner::PRIMITIVE ne "system1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # Ctrl-C is off in a new process group (Perl's kill INT, GenerateConsoleCtrlEvent, does not reach it either) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | my $group = $PRIMITIVE eq 'system1' || $at{win_new_group} || defined $at{pgroup} && !$at{pgroup}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$Proc::Spawner::PRIMITIVE eq 'system1' || $at{'win_new_group'} || defined $at{'pgroup'} && !$at{'pgroup'}
$Proc::Spawner::PRIMITIVE eq "system1" or $at{"win_new_group"}
defined $at{"pgroup"} and not $at{"pgroup"}
MC/DC0%0/4
$Proc::Spawner::PRIMITIVE eq 'system1' || $at{'win_new_group'} || defined $at{'pgroup'} && !$at{'pgroup'}
$Proc::Spawner::PRIMITIVE eq "system1"
$at{"win_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= $at{"win_new_group"}C= defined $at{"pgroup"}D= not $at{"pgroup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $at{sigignore} = [grep !($_ == $SIGNUM{PIPE} || $group && $_ == $SIGNUM{INT}), @{$at{sigignore}}] } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$_ == $Proc::Spawner::SIGNUM{'PIPE'} || $group && $_ == $Proc::Spawner::SIGNUM{'INT'}
$group and $_ == $Proc::Spawner::SIGNUM{"INT"}
MC/DC0%0/3
$_ == $Proc::Spawner::SIGNUM{'PIPE'} || $group && $_ == $Proc::Spawner::SIGNUM{'INT'}
$_ == $Proc::Spawner::SIGNUM{'PIPE'}
$group
$_ == $Proc::Spawner::SIGNUM{"INT"}
Truth table0%0/4
A || B and C
A= $_ == $Proc::Spawner::SIGNUM{'PIPE'}B= $groupC= $_ == $Proc::Spawner::SIGNUM{"INT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 1 | %$atr = %at; 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 1 | ▶ | sub spawn_unsupported { # spawn, step 3: the settings and file actions the primitive lacks, refused or dropped (%$at, @$acts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn_unsupported: called CC=47 SCAR=71.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # and the copy %$m of %MISSING changed); false, with $!, to fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | my ($atr, $actsr, $mr, $refuse) = @_; my %at = %$atr; my @acts = @$actsr; my %m = %$mr; # (copies, put back at the end) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | ▶ | if ($WIN) { # Windows, where the primitive lacks a setting (system1, Perl's own spawn; or a posix_spawn doing less than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # win_spawn.h, X64): what Windows does anyway, and what it cannot; nothing of POSIX's signal calls (Perl has none here) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | my $sys1 = $PRIMITIVE eq 'system1'; my $lacks = sub { $sys1 || $m{$_[0]} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | delete $at{$_} for grep $lacks->($_), qw(sigdefault resetids); # nothing is inherited, no set-user-id | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | delete $at{sigmask} if $lacks->('sigmask') && ref $at{sigmask} eq 'ARRAY' && !@{$at{sigmask}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
&$lacks("sigmask") and ref $at{"sigmask"} eq "ARRAY" and not @{$at{"sigmask"};}
&$lacks("sigmask") and ref $at{"sigmask"} eq "ARRAY"
MC/DC0%0/3
&$lacks("sigmask") and ref $at{"sigmask"} eq "ARRAY" and not @{$at{"sigmask"};}
&$lacks("sigmask")
ref $at{"sigmask"} eq "ARRAY"
not @{$at{"sigmask"};}
Truth table0%0/4
A and B and not(C)
A= &$lacks("sigmask")B= ref $at{"sigmask"} eq "ARRAY"C= not @{$at{"sigmask"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if ($lacks->('pgroup') && defined $at{pgroup} && !$at{pgroup}) { # a group of its own: system1 always makes one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
&$lacks("pgroup") and defined $at{"pgroup"} and not $at{"pgroup"}
&$lacks("pgroup") and defined $at{"pgroup"}
MC/DC0%0/3
&$lacks("pgroup") and defined $at{"pgroup"} and not $at{"pgroup"}
&$lacks("pgroup")
defined $at{"pgroup"}
not $at{"pgroup"}
Truth table0%0/4
A and B and not(C)
A= &$lacks("pgroup")B= defined $at{"pgroup"}C= not $at{"pgroup"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | $at{win_new_group} = 1 unless $sys1; delete $at{pgroup} } # posix_spawn by the XSUB's win_new_group | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | for my $n (grep $lacks->($_), 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 1 | ▶ | if ($PRIMITIVE eq 'system1' && $WIN) { # Perl's own spawn on Windows: the child sees fds 0-2 only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my @k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | for my $x (@acts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my ($op, @a) = @$x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | if ($op eq 'closefrom') { push @k, map [close => $_], $a[0] .. 2; next } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | push @k, $x } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | @acts = @k } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | my %d = map +($_ => 1), @{$at{sigdefault}}; if (grep $d{$_}, @{$at{sigignore}}) { $! = POSIX::EINVAL(); return } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if (grep $m{$_}, qw(dup2 close open closefrom)) { $m{$_} = 1 for qw(dup2 close open closefrom chdir fchdir) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sigignore => sub { ref $at{sigignore} eq 'ARRAY' && @{$at{sigignore}} }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | for my $n (qw(setsid sched cgroup rlimit sigignore nice)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | return if $refuse->($n); delete $at{$n} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | %$atr = %at; @$actsr = @acts; %$mr = %m; 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 1 | ▶ | sub spawn_sort_actions { # spawn, step 4: the file actions done here (in order) and those left to the primitive, as two | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn_sort_actions: called CC=11 SCAR=38.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # array references; empty, with $!, to fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | my ($actsr, $mr) = @_; my @acts = @$actsr; my %m = %$mr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | my %kind = (chdir => 'dir', fchdir => 'dir', dup2 => 'fd', close => 'fd', open => 'fd', closefrom => 'fd'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | my (@here, @there); # actions done here (in order), and those left to the primitive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | for my $x (@acts) { my $k = ref $x eq 'ARRAY' ? $x->[0] // '' : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$x->[0] // ""
MC/DC0%0/1
$x->[0] // ""
$x->[0]
Truth table0%0/2
A
A= $x->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ($m{$k} && $kind{$k}) { push @here, $x } else { push @there, $x } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$m{$k} and $kind{$k}
MC/DC0%0/2
$m{$k} and $kind{$k}
$m{$k}
$kind{$k}
Truth table0%0/3
A and B
A= $m{$k}B= $kind{$k}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 13 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 12 | my %pos; @pos{map 0 + $_, @acts} = 0 .. $#acts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | my $first_there = (sort { $a <=> $b } map $pos{0 + $_}, @there)[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my $last_here = (sort { $b <=> $a } map $pos{0 + $_}, @here)[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | if ($first_there < $last_here) { $! = POSIX::EINVAL(); return } } # (start() puts chdir first) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | (\@here, \@there) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 554 | our $PATH_SEP = $Config{path_sep}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | sub win_new_group { # Windows: is the child to be in a process group of its own? %WINDOWS{new_group}: 1 always, 0 never, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
win_new_group: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # 'auto' (the default; post-0.12, the user's W7) when the child would have SIGINT ignored on POSIX: sigignore has it, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | # ours is ignored and sigdefault does not set it back. Windows turns Ctrl-C off in a new group, as SIGINT ignored; a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # child that gets SIGINT at its default stays in our group and gets a Ctrl-C at the console itself, as on POSIX (and as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | # with Perl's own system: a new group only for a child it does not wait for, system 1, ...) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | my $at = shift; my $ng = $WINDOWS{new_group} // 'auto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Proc::Spawner::WINDOWS{"new_group"} // "auto"
MC/DC0%0/1
$Proc::Spawner::WINDOWS{"new_group"} // "auto"
$Proc::Spawner::WINDOWS{"new_group"}
Truth table0%0/2
A
A= $Proc::Spawner::WINDOWS{"new_group"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | return $ng ? 1 : 0 if $ng ne 'auto'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | my $int = $SIGNUM{INT} // 2; my $has = sub { my $l = $at->{$_[0]}; ref $l eq 'ARRAY' && grep $_ == $int, @$l }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
Condition0%0/2
$Proc::Spawner::SIGNUM{"INT"} // 2
MC/DC0%0/1
$Proc::Spawner::SIGNUM{"INT"} // 2
$Proc::Spawner::SIGNUM{"INT"}
Truth table0%0/2
A
A= $Proc::Spawner::SIGNUM{"INT"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | return 1 if $has->('sigignore'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | ($SIG{INT} // '') eq 'IGNORE' && !$has->('sigdefault') ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
($SIG{"INT"} // "") eq "IGNORE" and not &$has("sigdefault")
$SIG{"INT"} // ""
MC/DC0%0/2
($SIG{"INT"} // "") eq "IGNORE" and not &$has("sigdefault")
$SIG{"INT"}
not &$has("sigdefault")
Truth table0%0/3
A and not(B)
A= $SIG{"INT"}B= not &$has("sigdefault")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 295 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | # entry is the current directory. Windows (as Perl's own win32.c reads PATH): a "quoted" part is taken whole, its quotes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # dropped (an unclosed one runs to the end); empty entries are dropped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 295 | ▶ | 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()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 295 | ▶ | $WIN ? grep(length, map tr/"//dr, $p =~ /((?:"[^"]*(?:"|$)|[^"$s])*)/g) : split /$s/, $p, -1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 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=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | # PATHEXT's extensions before the bare name; a path as it is (relative: to the directory now) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | # (post-0.12, X57: relative to Perl's directory, Cwd::getcwd; rel2abs alone takes the process's, in a pseudo-process | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | # another one) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | my ($file, $search) = @_; my $here; require Cwd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 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[[/\\:]]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | for my $d (@dirs) { for my $e (@ext) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | my $p = length $d ? "$d\\$file$e" : "$file$e"; return File::Spec->rel2abs($p, $here //= Cwd::getcwd()) if -f $p && -x _ } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/6
-f $p and -x _
$here //= Cwd::getcwd()
MC/DC0%0/2
-f $p and -x _
-f $p
-x _
MC/DC0%0/2
$here //= Cwd::getcwd()
$here
Cwd::getcwd()
Truth table0%0/3
A and B
A= -f $pB= -x _
Truth table0%0/3
A //= B
A= $hereB= Cwd::getcwd()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | return } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 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=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my ($file, $argv, $envp, $search, $redirs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | require Run; Run->VERSION('0.07'); # (Run::start with a program, {fd => M}, {close => 1}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | local $Run::Forkless = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($WIN) { # posix_spawn's meaning of FILE (with search: PATH and PATHEXT), not Perl's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 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 _
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # a name given twice: the first, as getenv finds it and win_spawn.h passes it (post-0.12, X58: %ENV kept the last); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # on Windows names are the same in any case | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | my %seen; local %ENV = map { /^([^=]+)=(.*)\z/s && !$seen{$WIN ? uc $1 : $1}++ ? ($1, $2) : () } @$envp if $envp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
/^([^=]+)=(.*)\z/s and not $seen{$Proc::Spawner::WIN ? uc $1 : $1}++
MC/DC0%0/2
/^([^=]+)=(.*)\z/s and not $seen{$Proc::Spawner::WIN ? uc $1 : $1}++
/^([^=]+)=(.*)\z/s
not $seen{$Proc::Spawner::WIN ? uc $1 : $1}++
Truth table0%0/3
A and not(B)
A= /^([^=]+)=(.*)\z/sB= not $seen{$Proc::Spawner::WIN ? uc $1 : $1}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # X38 (post-0.10): Perl's spawn on Windows passes the child every inheritable handle, and Perl makes its handles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | # inheritable (no close-on-exec by $^F there): our fds from 3 up are made not inheritable for the call, then put back, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # as POSIX has it. Not thread-safe: another thread's spawn meanwhile does not pass these fds either. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | my @off = $WIN ? grep(__fd_cloexec($_) == 0, 3 .. __fd_limit() - 1) : (); __set_cloexec($_, 1) for @off; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my @errs; my $pid = eval { Run::start(1, $argv, $redirs, \@errs, $file) }; my ($died, $err) = ($@, $!); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | __set_cloexec($_, 0) for @off; die $died if $died; $! = $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $pid or return; $pid } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub dir_change { # JH5 (a, post-0.12): chdir or fchdir in this process; the first time, this process's directory is kept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir_change: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my ($op, $to, $here, $die) = @_; # in $$here (an fd of it, close-on-exec; Windows: its path), for dir_back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 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()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 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
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | ($op eq 'chdir' ? chdir $to : __fchdir($to)) or $die->() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | sub dir_back { my $here = shift; return unless defined $here; # back to the directory dir_change kept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir_back: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if ($WIN) { chdir $here } else { __fchdir($here); POSIX::close($here) } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 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=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # our fds back); chdir and fchdir done here, in order, so that an open's relative path is taken from the directory then; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | # the way back pushed on @$undo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my ($acts, $undo) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my (@r, $here, @opened); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | my $die = sub { die "Proc::Spawner: errno " . (0 + $!) . "\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 7 | ▶ | unshift @$undo, sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | close $_ for @opened; dir_back($here) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | for my $x (@$acts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my ($op, @a) = @$x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | if ($op eq 'chdir' || $op eq 'fchdir') { dir_change($op, $a[0], \$here, $die) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | elsif ($op eq 'dup2') { push @r, $a[1] => { fd => $a[0] } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | elsif ($op eq 'close') { push @r, $a[0] => { close => 1 } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | elsif ($op eq 'open') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 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]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | push @r, $a[0] => { filehandle => $fh, pin => 1 } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | elsif ($op eq 'closefrom') { push @r, map +($_ => { close => 1 }), grep __fd_cloexec($_) == 0, $a[0] .. __fd_limit() - 1 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | else { $! = POSIX::EINVAL(); $die->() } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | \@r } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 14 | ▶ | sub emulate_actions { # the file actions, done on this process's own fds in order; the way back pushed on @$undo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
emulate_actions: called CC=30 SCAR=65.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my ($acts, $undo) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $top = 10; # above every fd the actions name (not an open's flags or mode) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my (%flag, %save, %ours); # an fd's close-on-exec before (-1: was not open); its contents before (a copy; undef: none) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | my $die = sub { die "Proc::Spawner: errno " . (0 + $!) . "\n" }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | my $flag_touch = sub { my $fd = shift; $flag{$fd} //= __fd_cloexec($fd) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=11.6
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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | my $content_touch = sub { my $fd = shift; return if exists $save{$fd}; $flag_touch->($fd); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=20.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $here; # this process's directory before | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 7 | ▶ | unshift @$undo, sub { # contents first, then the flags, then the directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=31.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | for my $fd (keys %flag) { __set_cloexec($fd, $flag{$fd}) if $flag{$fd} >= 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | dir_back($here) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | for my $x (@$acts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | my ($op, @a) = @$x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if ($op eq 'chdir' || $op eq 'fchdir') { dir_change($op, $a[0], \$here, $die); $ours{$here} = 1 unless $WIN } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | elsif ($op eq 'dup2') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my ($from, $to) = @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | ▶ | if ($from == $to) { __fd_cloexec($from) >= 0 or do { $! = POSIX::EBADF(); $die->() }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $flag_touch->($to); __set_cloexec($to, 0) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | else { __fd_cloexec($from) >= 0 or do { $! = POSIX::EBADF(); $die->() }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $content_touch->($to); defined POSIX::dup2($from, $to) or $die->() } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # spawn passes the standard handles, inheritable or not) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | elsif ($op eq 'close') { $flag_touch->($a[0]); __set_cloexec($a[0], 1) if __fd_cloexec($a[0]) >= 0 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | elsif ($op eq 'closefrom') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | for my $fd ($a[0] .. __fd_limit() - 1) { next if $ours{$fd} || __fd_cloexec($fd) < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $flag_touch->($fd); __set_cloexec($fd, 1) } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | elsif ($op eq 'open') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my ($fd, $path, $fl, $mode) = @a; $content_touch->($fd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if ($o == $fd) { __set_cloexec($fd, 0) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | else { my $r = POSIX::dup2($o, $fd); my $e = $!; POSIX::close($o); defined $r or do { $! = $e; $die->() } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 7 | else { $! = POSIX::EINVAL(); $die->() } } } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | # The loop is Proc::Spawner::Loop (W5, post-0.10); these are its variables, and the functions below its old names. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 554 | ▶ | use Proc::Spawner::Loop (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 554 | our ($TRACE, $CAUSE, $REACTING, $DEPTH); # undef or a code ref given one line per operation; the caller's cause (Graph) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 554 | *TRACE = \$Proc::Spawner::Loop::TRACE; *CAUSE = \$Proc::Spawner::Loop::CAUSE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 554 | *REACTING = \$Proc::Spawner::Loop::REACTING; *DEPTH = \$Proc::Spawner::Loop::DEPTH; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1019 | ▶ | sub tr_ { $TRACE->(join '', @_) if $TRACE } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tr_: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # ------------------------------------------------------------------ spawning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 373 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 359 | my $fds = shift; my @t = sort { $a <=> $b } keys %$fds; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 359 | ▶ | 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($_)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 359 | ▶ | my $top = 9; for (@t, @src) { $top = $_ if $_ > $top } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 359 | my (@a, @open, %via, @scratch); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 359 | for my $f (@src) { # a source fd the child gets something else on: copy it first | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 266 | ▶ | 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}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 11 | push @a, [dup2 => $f, $via{$f} = ++$top]; push @scratch, $top } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 359 | for my $t (@t) { # dup2 to itself too: it clears close-on-exec | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 271 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 359 | @a, @open, map [close => $_], (grep !defined $fds->{$_}, @t), @scratch } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 712 | ▶ | 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
$Proc::Spawner::SIGNUM{$_} // (/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
$_[0] // []
MC/DC0%0/2
$Proc::Spawner::SIGNUM{$_} // (/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
$Proc::Spawner::SIGNUM{$_}
(/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
MC/DC100%1/1
$_[0] // []
$_[0]
Truth table33%1/3
A // B
A= $Proc::Spawner::SIGNUM{$_}B= (/^[0-9]+\z/ ? $_ : die("Proc::Spawner: unknown signal '${_}'\n"))
Truth table100%2/2
A
A= $_[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 554 | ▶ | my %RLIMIT = defined &__rlimits ? __rlimits() : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 15 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 8 | my $h = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 51 | map { my ($n, $v) = ($_, $h->{$_}); (my $k = uc $n) =~ s/^RLIMIT_//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 15 | ▶ | my $r = $WIN ? $k : $RLIMIT{$k} // ($n =~ /^[0-9]+\z/ ? $n : die "Proc::Spawner: unknown resource '$n'\n"); # (Windows: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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"))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | # the name, W4) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 1 | ▶ | [$r, ref $v ? @$v[0, 1] : ($v, undef)] } sort keys %$h } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 352 | ▶ | sub start { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 352 | my ($path, $argv, $envp, $fds, %o) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | my @a = ((map [$_ => $o{$_}], grep defined $o{$_}, qw(chdir fchdir)), actions($fds), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 352 | ▶ | defined $o{tcsetpgrp} ? [tcsetpgrp => $o{tcsetpgrp}] : ()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | my %attr = (sigmask => [signums($o{sigmask})], sigdefault => [signums($o{sigdefault})], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 353 | map +($_ => $o{$_}), grep exists $o{$_}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | qw(pgroup setsid resetids sched cgroup search pidfd nice win_priority win_job)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 352 | ▶ | $attr{sigignore} = [signums($o{sigignore})] if $o{sigignore}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 353 | ▶ | $attr{rlimit} = [rlimits($o{rlimit})] if $o{rlimit}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 353 | ▶ | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 353 | my ($pid, $pidfd) = spawn($path, $argv, $envp, \@a, \%attr, $o{unsupported}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 353 | ▶ | { local $!; umask $um if defined $o{umask} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 353 | my $how = join ', ', map "$$_[0] " . join('->', @$_[1 .. $#$_]), @a; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 353 | ▶ | $pid or return tr_("spawn failed: @$argv: $!"), undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 349 | ▶ | tr_("spawn $pid: $path [@$argv]", @a ? "; $how" : ''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 349 | my $cb = $o{on_exit}; # (Windows: the kept process handle is released once the status is taken, post-0.08) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 349 | ▶ | loop()->child($pid, sub { reaped($pid); $cb->(@_) if $cb }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 349 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # ------------------------------------------------------------------ the loop: Proc::Spawner::Loop under its old names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 338 | ▶ | sub reaped { # after waiting for a child of spawn: on Windows the kept process handle is released (post-0.08); else nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reaped: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # (post-0.12, X59: gone with W5, post-0.10, though documented: a caller who waited itself could not release it) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 339 | ▶ | __win_spawn_forget($_[0]) if $WIN && defined &__win_spawn_forget } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$Proc::Spawner::WIN and defined &Proc::Spawner::__win_spawn_forget
MC/DC0%0/2
$Proc::Spawner::WIN and defined &Proc::Spawner::__win_spawn_forget
$Proc::Spawner::WIN
defined &Proc::Spawner::__win_spawn_forget
Truth table33%1/3
A and B
A= $Proc::Spawner::WINB= defined &Proc::Spawner::__win_spawn_forget
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 6777 | ▶ | sub loop { Proc::Spawner::Loop->new } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 3097 | ▶ | sub defer { loop()->defer(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
defer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 585 | ▶ | sub wait_until { loop()->wait_until(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wait_until: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 12 | ▶ | sub poll { loop()->poll } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
poll: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | ▶ | sub turn { loop()->turn(@_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
turn: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 1868 | ▶ | sub on_read { my ($fd, $n, $cb) = @_; loop()->read($fd, $n, $cb) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_read: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 864 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 554 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||