Blob
- Date:
- Message:
- refactor the parsing into the module change the mscan format string to siplify the parsing, and refactor the parsing code into the module for reuse. pe is an exception in that it doesn't care about the format string, it just need to decide if the current line starts a new thread or not, that's why it doesn't use the newly introduced `parse'. The new format simplifies pe too though.
- Actions:
- History | Blame | Raw File
1 #!/usr/bin/env perl3 use open ":std", ":encoding(UTF-8)";4 use strict;5 use warnings;6 use v5.32;7 use IO::Poll qw(POLLOUT);9 use OpenBSD::Pledge;10 use OpenBSD::Unveil;12 my $jobs = $ENV{'MAKE_JOBS'} // 1;14 my $poll = IO::Poll->new();15 for (1..$jobs) {16 open(my $kid, '|-', './mexp') or die "can't exec ./mexp: $!";17 $poll->mask($kid => POLLOUT);18 }20 sub process {21 die "poll: $!" if $poll->poll() == -1;22 my @handles = $poll->handles(POLLOUT) or die "no procs ready?";23 my $handle = $handles[int(rand(@handles))];24 print $handle $_ foreach @_;25 }27 unveil("./mexp", "rx") or die "unveil mexp: $!";28 pledge("stdio proc exec") or die "pledge: $!";30 my @thread;31 while (<>) {32 print; # continue the pipeline34 my $new_thread = m/^-/;35 if ($new_thread && @thread) {36 process @thread;37 @thread = ();38 }40 push @thread, $_;41 }43 process @thread if @thread;