blob: 02ee23ebb84573ad6f59fd68abe61410d24123c8 (
plain) (
blame)
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 mill.scalalib.backgroundwrapper;
public class BackgroundWrapper {
public static void main(String[] args) throws Exception{
String watched = args[0];
String tombstone = args[1];
String expected = args[2];
Thread watcher = new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try{
Thread.sleep(50);
String token = new String(
java.nio.file.Files.readAllBytes(java.nio.file.Paths.get(watched))
);
if (!token.equals(expected)) {
new java.io.File(tombstone).createNewFile();
System.exit(0);
}
}catch(Exception e){
try {
new java.io.File(tombstone).createNewFile();
}catch(Exception e2){}
System.exit(0);
}
}
}
});
watcher.setDaemon(true);
watcher.start();
String realMain = args[3];
String[] realArgs = new String[args.length - 4];
for(int i = 0; i < args.length-4; i++){
realArgs[i] = args[i+4];
}
Class.forName(realMain).getMethod("main", String[].class).invoke(null, (Object)realArgs);
}
}
|