Skip to content

Commit

Permalink
feat(gabriel): don't use process substitution because it may end up a…
Browse files Browse the repository at this point in the history
…s zombie process
  • Loading branch information
fushar committed Jun 17, 2023
1 parent 9c90ede commit f79a108
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import judgels.gabriel.api.Verdict;

public class DiffScorer implements Scorer {
private static final String DIFF_COMMAND = "/usr/bin/diff --brief";
private static final String TOKENIZER_COMMAND = " <(cat \"%s\" | tr '[\\t\\r\\n]' ' ' | xargs)";

@Override
public ScoringResult score(File input, File output, File evaluationOutput) throws ScoringException {
String[] scoringCommand = new String[]{"bash", "-c", String.format(
DIFF_COMMAND + TOKENIZER_COMMAND + TOKENIZER_COMMAND,
String[] scoringCommand = new String[]{"/bin/bash", "-c", String.format(""
+ "cat \"%s\" | tr '[\\t\\r\\n]' ' ' | xargs > _output.out; "
+ "cat \"%s\" | tr '[\\t\\r\\n]' ' ' | xargs > _evaluation.out; "
+ "diff --brief _output.out _evaluation.out; result=$?; "
+ "rm _output.out _evaluation.out; "
+ "exit $result;",
output.getAbsolutePath(),
evaluationOutput.getAbsolutePath())};

Expand Down

0 comments on commit f79a108

Please sign in to comment.