3 # pe was written by Omar Polo <op@openbsd.org> and is placed in the
4 # public domain. The author hereby disclaims copyright to this source
7 use open ":std", ":encoding(UTF-8)";
11 use IO::Poll qw(POLLOUT);
16 my $jobs = $ENV{'MAKE_JOBS'} // 1;
18 my $poll = IO::Poll->new();
20 open(my $kid, '|-', './mexp') or die "can't exec ./mexp: $!";
21 $poll->mask($kid => POLLOUT);
25 die "poll: $!" if $poll->poll() == -1;
26 my @handles = $poll->handles(POLLOUT) or die "no procs ready?";
27 my $handle = $handles[int(rand(@handles))];
28 print $handle $_ foreach @_;
31 unveil("./mexp", "rx") or die "unveil mexp: $!";
32 pledge("stdio proc exec") or die "pledge: $!";
36 print; # continue the pipeline
38 my $new_thread = m/^-/;
39 if ($new_thread && @thread) {
47 process @thread if @thread;