Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 1 addition & 28 deletions src/test/java/au/com/southsky/jfreesane/SaneDaemonRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected void before() throws Throwable {
return;
}

saneDaemonBuilder = new ProcessBuilder("saned", "-l", "-p", "0", "-e", "-d", "8");
saneDaemonBuilder = new ProcessBuilder("saned", "-l", "-p", "0", "-e", "-d", "8", "-o");
saneDaemonBuilder.directory(tempDir.getRoot());
}

Expand Down Expand Up @@ -123,33 +123,6 @@ public void protectDevice(String name, String username, String password) {
passwords.add(auth);
}

@Override
protected void after() {
if (saneDaemon == null) {
return;
}

if (saneDaemon.isAlive()) {
logger.fine("Stopping SANE daemon");
saneDaemon.descendants().forEach(ProcessHandle::destroy);
saneDaemon.destroy();
}

try {
if (saneDaemon.waitFor(10, TimeUnit.SECONDS)) {
logger.info("SANE daemon exited with status " + saneDaemon.exitValue());
} else {
logger.info("Timed out waiting for SANE daemon to exit, forcibly terminating.");
}
} catch (InterruptedException e) {
logger.info("Interrupted while waiting for SANE daemon to exit, forcibly terminating.");
Thread.currentThread().interrupt();
} finally {
// This is a nop if the process is gone already.
saneDaemon.destroyForcibly();
}
}

private static final class SaneLogListener extends Thread {
private static final Pattern PORT_TYPE_PATTERN =
Pattern.compile("\\[(\\d+)] socket .* using IPv([4|6])$");
Expand Down
Loading