forked from processing/processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProcessRegistry.java
More file actions
40 lines (34 loc) · 873 Bytes
/
ProcessRegistry.java
File metadata and controls
40 lines (34 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package processing.app.exec;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public class ProcessRegistry {
private static final Set<Process> REGISTRY = Collections
.synchronizedSet(new HashSet<Process>());
static {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
synchronized (REGISTRY) {
for (final Process p : REGISTRY) {
try {
// System.err.println("Cleaning up rogue process " + p);
p.destroy();
} catch (final Exception drop) {
}
}
}
}
});
}
/**
* When starting up a process
* @param p
*/
public static void watch(final Process p) {
REGISTRY.add(p);
}
public static void unwatch(final Process p) {
REGISTRY.remove(p);
}
}