Blob
Date:
Mon Aug 29 20:53:44 2022 UTC
Message:
state the license on each file
#!/usr/bin/env perl
#
# pe was written by Omar Polo <op@openbsd.org> and is placed in the
# public domain. The author hereby disclaims copyright to this source
# code.
use open ":std", ":encoding(UTF-8)";
use strict;
use warnings;
use v5.32;
use IO::Poll qw(POLLOUT);
use OpenBSD::Pledge;
use OpenBSD::Unveil;
my $jobs = $ENV{'MAKE_JOBS'} // 1;
my $poll = IO::Poll->new();
for (1..$jobs) {
open(my $kid, '|-', './mexp') or die "can't exec ./mexp: $!";
$poll->mask($kid => POLLOUT);
}
sub process {
die "poll: $!" if $poll->poll() == -1;
my @handles = $poll->handles(POLLOUT) or die "no procs ready?";
my $handle = $handles[int(rand(@handles))];
print $handle $_ foreach @_;
}
unveil("./mexp", "rx") or die "unveil mexp: $!";
pledge("stdio proc exec") or die "pledge: $!";
my @thread;
while (<>) {
print; # continue the pipeline
my $new_thread = m/^-/;
if ($new_thread && @thread) {
process @thread;
@thread = ();
}
push @thread, $_;
}
process @thread if @thread;
Omar Polo