fix injection error handling

This commit is contained in:
2026-04-18 17:42:14 +02:00
parent cf319c5a72
commit 540596c33d

View File

@ -77,29 +77,6 @@ sub update_db_config {
say "Updated db.conf for database $db_prefix\_$experiment";
}
sub wait_for_port {
my ( $host, $port, $timeout ) = @_;
my $deadline = time + $timeout;
while ( time < $deadline ) {
my $sock = IO::Socket::INET->new(
PeerHost => $host,
PeerPort => $port,
Proto => 'tcp',
Timeout => 1,
);
if ($sock) {
close $sock;
return 1;
}
select undef, undef, undef, 0.1;
}
return 0;
}
sub cpu_count {
open( my $handle, "/proc/cpuinfo" ) or die "Can't open cpuinfo: $!\n";
my $count = scalar( map /^processor/, <$handle> );
@ -269,14 +246,13 @@ sub inject {
"--inject-single-bit",
"--inject-registers"
)
) or die "exec server failed: $!";
) == 0 or die "exec server failed: $!";
}
# parent -> client
say "Waiting for server...";
die "Server did not become ready on port $fail_server_port\n"
unless wait_for_port( "127.0.0.1", $fail_server_port, 10 );
sleep(10);
say "Running client with $count cores in parent process";
@ -303,7 +279,7 @@ sub inject {
"-Wf,--detected-marker=fail_marker_detected",
">/dev/null"
)
) or die "client failed: $?";
) == 0 or die "client failed: $?";
say "Killing server with pid $pid...";
kill 'TERM', $pid;