-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestart_run
executable file
·59 lines (47 loc) · 1.55 KB
/
restart_run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!perl
use v5.22;
use feature qw(signatures);
no warnings qw(experimental::signatures);
use FindBin qw($Bin);
use lib "$Bin/../lib";
use Data::Dumper;
use File::Path qw(make_path);
use File::Spec::Functions qw(catfile updir);
use Getopt::Long qw(GetOptions);
use POSIX qw(ceil :sys_wait_h);
my $output_dir = catfile( $Bin, '..', 'output' );
my $length = $ARGV[0] or die "Tell me the length!\n";
$|++;
opendir my $dh, $output_dir or die "Could not open $output_dir";
while( my $file = readdir $dh ) {
next unless $file =~ / \A \Q$length\E \. /x;
say "$file";
my $path = catfile( $output_dir, $file );
open my $fh, '<:utf8', $path or warn "Could not open [$path]: $!\n";
my $end = 0;
my $progress = 0;
LINE: while( <$fh> ) {
chomp;
if( / \A \Q***\E \s+ \[(?<pid>[0-9]+)] \s+ end \s+ a \s+ is \s+ (?<end>[0-9]+) /x ) {
$end = $+{end};
say "\tEnd is $end";
next LINE;
}
elsif( / \A \Q+++\E \s+ \[(?<pid>[0-9]+)] \s+ Checked \s+ \[(?<start>[0-9]+)] \s+ to \s+ \[(?<progress>[0-9]+)] /x ) {
$progress = $+{progress};
next LINE;
}
}
my $command = catfile( 'c', 'excellent-128' );
my @args = ( $command, $length, $progress, $end );
if( my $child_pid = fork ) { # parent
say "*** Parent process $$ forked child $child_pid, saving in $path";
}
else { # child
open STDOUT, '>>:utf8', $path or die "Could not open $path: $!\n";
exec { $args[0] } @args or die "Could not exec! $!";
}
}
__END__
*** [46345] start a is 612571428571468
*** [46345] end a is 620000000000000