@Test public void getPidsDoesntGetChildDirectoryPids() throws IOException { Files.createDirectories(defaultProcRoot); Path firstSubfolder = defaultProcRoot.resolve(fs.getPath("firstSubfolder")); Path secondSubfolder = defaultProcRoot.resolve(fs.getPath("secondSubfolder")); Files.createDirectory(firstSubfolder); Files.createDirectory(secondSubfolder); createIncrementingPidsInRoot(firstSubfolder, LinuxConstants.LOWEST_LEGAL_PID, 3); createIncrementingPidsInRoot(secondSubfolder, LinuxConstants.LOWEST_LEGAL_PID, 7); List<Integer> pids = enumerator.getPids(); assertTrue(pids.isEmpty()); }
@Override public List<Integer> getPids() { int pidMax = readPidMax(); BiPredicate<Path, BasicFileAttributes> filter = new ProcPathFilter(pidMax); try { return Files.find(procRoot, 1, filter) .map(path -> Integer.parseUnsignedInt(path.getFileName().toString())) .collect(Collectors.toList()); } catch (IOException ex) { throw new ProcessEnumerationException("An error occurred while enumerating PIDs", ex); } }
LinuxPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int pidMax = readPidMax(); BiPredicate<Path, BasicFileAttributes> filter = new ProcPathFilter(pidMax); try { return Files.find(procRoot, 1, filter) .map(path -> Integer.parseUnsignedInt(path.getFileName().toString())) .collect(Collectors.toList()); } catch (IOException ex) { throw new ProcessEnumerationException("An error occurred while enumerating PIDs", ex); } } }
LinuxPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int pidMax = readPidMax(); BiPredicate<Path, BasicFileAttributes> filter = new ProcPathFilter(pidMax); try { return Files.find(procRoot, 1, filter) .map(path -> Integer.parseUnsignedInt(path.getFileName().toString())) .collect(Collectors.toList()); } catch (IOException ex) { throw new ProcessEnumerationException("An error occurred while enumerating PIDs", ex); } } LinuxPidEnumerator(Path procRoot, Path pathToPidMax); }
LinuxPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int pidMax = readPidMax(); BiPredicate<Path, BasicFileAttributes> filter = new ProcPathFilter(pidMax); try { return Files.find(procRoot, 1, filter) .map(path -> Integer.parseUnsignedInt(path.getFileName().toString())) .collect(Collectors.toList()); } catch (IOException ex) { throw new ProcessEnumerationException("An error occurred while enumerating PIDs", ex); } } LinuxPidEnumerator(Path procRoot, Path pathToPidMax); @Override List<Integer> getPids(); }
LinuxPidEnumerator implements PidEnumerator { @Override public List<Integer> getPids() { int pidMax = readPidMax(); BiPredicate<Path, BasicFileAttributes> filter = new ProcPathFilter(pidMax); try { return Files.find(procRoot, 1, filter) .map(path -> Integer.parseUnsignedInt(path.getFileName().toString())) .collect(Collectors.toList()); } catch (IOException ex) { throw new ProcessEnumerationException("An error occurred while enumerating PIDs", ex); } } LinuxPidEnumerator(Path procRoot, Path pathToPidMax); @Override List<Integer> getPids();  }