Skip to content

Framework to watch processes and execute arbitrary commands on termination.

Notifications You must be signed in to change notification settings

cinchapi/process-watcher

Folders and files

NameName
Last commit message
Last commit date
Jun 30, 2021
Oct 24, 2016
Jun 23, 2017
Oct 26, 2016
Jun 23, 2017
Oct 26, 2016
Jun 30, 2021
Oct 24, 2016
Oct 25, 2016
Oct 24, 2016

Repository files navigation

process-watcher

A Java framework that watches external processes for liveliness and executes arbitrary commands when they terminate.

Usage

The most common use case is embedding the process-watcher into an application that should terminate itself when the an external process terminates.

public static void main(String... args) {
  Thread t = new Thread(() -> {
    String pid = "61257";
    ProcessWatcher watcher = new ProcessWatcher();
    CountDownLatch signal = new CountDownLatch(1);
    watcher.watch(pid, () -> {
      System.out.println("The watched process has terminated");
      signal.countDown();
    });
  });
  t.setDaemon(true);
  t.start();
  // TODO: add other actions
  try {
    signal.await();
  }
  catch (InterruptedException e) {
    throw new RuntimeException(e);
  }
}

About

Framework to watch processes and execute arbitrary commands on termination.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published